Class PopupPanel
A panel that can "pop up" over other widgets. It overlays the browser's
client area (and any previously-created popups).

Example
public class PopupPanelExample implements EntryPoint, ClickListener {
private static class MyPopup extends PopupPanel {
public MyPopup() {
// PopupPanel's constructor takes 'auto-hide' as its boolean parameter.
// If this is set, the panel closes itself automatically when the user
// clicks outside of it.
super(true);
// PopupPanel is a SimplePanel, so you have to set it's widget property to
// whatever you want its contents to be.
setWidget(new Label("Click outside of this popup to close it"));
}
}
public void onModuleLoad() {
Button b = new Button("Click me");
b.addClickListener(this);
RootPanel.get().add(b);
}
public void onClick(Widget sender) {
// Instantiate the popup and show it.
new MyPopup().show();
}
}
Constructors
Methods
add(Widget) | |
addPopupListener(PopupListener) | Adds a listener interface to receive popup events. |
hide() | Hides the popup. |
onEventPreview(Event) | Called when a browser event occurs and this event preview is on top of the
preview stack. |
onKeyDownPreview(char, int) | Popups get an opportunity to preview keyboard events before they are passed
to any other widget. |
onKeyPressPreview(char, int) | Popups get an opportunity to preview keyboard events before they are passed
to any other widget. |
onKeyUpPreview(char, int) | Popups get an opportunity to preview keyboard events before they are passed
to any other widget. |
removePopupListener(PopupListener) | Removes a previously added popup listener. |
setHeight(String) | Sets the object's height. |
setPixelSize(int, int) | Sets the object's size, in pixels, not including decorations such as
border, margin, and padding. |
setPopupPosition(int, int) | Sets the popup's position relative to the browser's client area. |
setStyleName(String) | Sets the object's style name, removing all other styles. |
setWidth(String) | Sets the object's width. |
show() | Shows the popup. |
Constructor Detail
PopupPanel
public PopupPanel()
Creates an empty popup panel. A child widget must be added to it before it
is shown.
PopupPanel
public PopupPanel(boolean autoHide)
Creates an empty popup panel, specifying its "auto-hide" property.
Parameters
- autoHide
-
true
if the popup should be automatically
hidden when the user clicks outside of it
Method Detail
add
Parameters
- w
-
addPopupListener
Adds a listener interface to receive popup events.
Parameters
- listener
- the listener interface to add.
hide
public void hide()
Hides the popup. This has no effect if it is not currently visible.
onEventPreview
public boolean
onEventPreview(
Event event)
Called when a browser event occurs and this event preview is on top of the
preview stack.
Parameters
- event
- the browser event
Return Value
false
to cancel the event
See Also
DOM.addEventPreview(EventPreview)
onKeyDownPreview
public boolean onKeyDownPreview(char key, int modifiers)
Popups get an opportunity to preview keyboard events before they are passed
to any other widget.
Parameters
- key
- the key code of the depressed key
- modifiers
- keyboard modifiers, as specified in
KeyboardListener.
Return Value
false
to suppress the event
onKeyPressPreview
public boolean onKeyPressPreview(char key, int modifiers)
Popups get an opportunity to preview keyboard events before they are passed
to any other widget.
Parameters
- key
- the unicode character pressed
- modifiers
- keyboard modifiers, as specified in
KeyboardListener.
Return Value
false
to suppress the event
onKeyUpPreview
public boolean onKeyUpPreview(char key, int modifiers)
Popups get an opportunity to preview keyboard events before they are passed
to any other widget.
Parameters
- key
- the key code of the released key
- modifiers
- keyboard modifiers, as specified in
KeyboardListener.
Return Value
false
to suppress the event
removePopupListener
Removes a previously added popup listener.
Parameters
- listener
- the listener interface to remove.
setHeight
public void
setHeight(
String height)
Sets the object's height. This height does not include decorations such as
border, margin, and padding.
Parameters
- height
- the object's new height, in CSS units (e.g. "10px", "1em")
setPixelSize
public void setPixelSize(int width, int height)
Sets the object's size, in pixels, not including decorations such as
border, margin, and padding.
Parameters
- width
- the object's new width, in pixels
- height
- the object's new height, in pixels
setPopupPosition
public void setPopupPosition(int left, int top)
Sets the popup's position relative to the browser's client area.
Parameters
- left
- the left position, in pixels
- top
- the top position, in pixels
setStyleName
public void
setStyleName(
String style)
Sets the object's style name, removing all other styles.
The style name is the name referred to in CSS style rules (in HTML, this is
referred to as the element's "class"). By convention, style rules are of
the form [project]-[widget]
(e.g. the Button widget's
style name is .gwt-Button
).
For example, if a widget's style name is myProject-MyWidget
,
then the style rule that applies to it will be
.myProject-MyWidget
. Note the "dot" prefix -- this is
necessary because calling this method sets the underlying element's
className
property.
An object may have any number of style names, which may be manipulated
using addStyleName(String) and removeStyleName(String).
The attributes of all styles associated with the object will be applied to
it.
Parameters
- style
- the style name to be added
See Also
addStyleName(String),
removeStyleName(String)
setWidth
public void
setWidth(
String width)
Sets the object's width. This width does not include decorations such as
border, margin, and padding.
Parameters
- width
- the object's new width, in CSS units (e.g. "10px", "1em")
show
public void show()
Shows the popup. It must have a child widget before this method is called.