How to change image for closing window in WindowPanel

1 view
Skip to first unread message

bernhard

unread,
Aug 4, 2010, 7:45:25 AM8/4/10
to gwt-mosaic
Hello,

I am new to gwt-mosaic. (A great library b.t.w.!)
Here is a question regarding the WindowPanel.
How can I replace the predefined image for this Panel?
I saw this definition in the WindowPanel class:
private static final Image image =
Caption.IMAGES.windowClose().createImage();
and the image wil be assigned in the constuctor:
// (ggeorg) Issue 51
final ImageButton closeBtn = new ImageButton(new
Image(image.getUrl(),
image.getOriginLeft(), image.getOriginTop(), image.getWidth(),
image.getHeight()));
closeBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
hide();
}
});

Is there a way to overwrite the assigment for the closing window
image?
I found examples for adding images, but none for the replacing.

Any suggestion are appreceated!

Thanks

Bernhard

bernhard

unread,
Aug 12, 2010, 9:32:33 AM8/12/10
to gwt-mosaic
Hello,

I found following method in the WindowPanel class:
// (ggeorg) Issue 51
final ImageButton closeBtn = new ImageButton(new
Image(image.getUrl(),
image.getOriginLeft(), image.getOriginTop(), image.getWidth(),
image.getHeight()));
closeBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
hide();
}
});
Is there a way to overwrite the predefined definition of the close
button?
I my case I need to display a confirmation window if the user clicks
the close button.

Thanks

Bernhard

ctasada

unread,
Aug 13, 2010, 7:58:42 AM8/13/10
to gwt-mosaic
Hi Bernhard,

You can either use the addWindowClosingHandler from the WindowPanel or
directly set a new button with your image/text and add a clickHandler,
of course, then you'll need to deal with the windows close by
yourself.

Check the documentation and examples. Are quite complete.

bernhard

unread,
Aug 13, 2010, 11:42:37 AM8/13/10
to gwt-mosaic
Hello,

thanks for the hint. Replacing the closing handler can be done easy:
final WindowPanel w = new WindowPanel("My Frame");
w. addWindowClosingHandler(new ClosingHandler() {
public void onWindowClosing(ClosingEvent event) {
InfoPanel.show(w.getCaption(), "onWindowClosed()");

}
});
Adding buttons (maximize, minimize) is also no problem like described
in the documentation.
but replacing the window close button seems not so easy because the
closing button will be set in the constructor of WindowPanel like
follows:
...Constructor of WindowPanel:
...
// (ggeorg) Issue 51
final ImageButton closeBtn = new ImageButton(new
Image(image.getUrl(),
image.getOriginLeft(), image.getOriginTop(), image.getWidth(),
image.getHeight()));
,,,
I did not find a accessible method for replacement of the predefined
close button in WindowPanels class.
Maybe there is a way for the replacement of the close button that I
don't know?

Kind regards

Bernhard

ctasada

unread,
Aug 16, 2010, 3:33:13 AM8/16/10
to gwt-mosaic
To "replace" the close button you really need to do the next:

Caption header = this.getHeader();
header.clear();

This will clean ALL the elements from the header.

Now you can add you own buttons and labels ;)
Reply all
Reply to author
Forward
0 new messages