Class PopupWindow
- All Implemented Interfaces:
EventTarget
- Direct Known Subclasses:
-
Popup,PopupControl
public abstract class PopupWindow extends Window
Popup and Tooltip and ContextMenu. A PopupWindow is a secondary window which has no window decorations or title bar. It doesn't show up in the OS as a top-level window. It is typically used for tool tip like notification, drop down boxes, menus, and so forth.
The PopupWindow cannot be shown without an owner. PopupWindows require that an owner window exist in order to be shown. However, it is possible to create a PopupWindow ahead of time and simply set the owner (or change the owner) before first being made visible. Attempting to change the owner while the PopupWindow is visible will result in an IllegalStateException.
The PopupWindow encapsulates much of the behavior and functionality common to popups, such as the ability to close when the "esc" key is pressed, or the ability to hide all child popup windows whenever this window is hidden. These abilities can be enabled or disabled via properties.
- Since:
- JavaFX 2.0
Property Summary
| Type | Property | Description |
|---|---|---|
final ObjectProperty<PopupWindow.AnchorLocation> |
anchorLocation |
Specifies the popup anchor point which is used in popup positioning. |
final ReadOnlyDoubleProperty |
anchorX |
Specifies the x coordinate of the popup anchor point on the screen. |
final ReadOnlyDoubleProperty |
anchorY |
Specifies the y coordinate of the popup anchor point on the screen. |
final BooleanProperty |
autoFix |
This convenience variable indicates whether, when the popup is shown, it should automatically correct its position such that it doesn't end up positioned off the screen. |
final BooleanProperty |
autoHide |
Specifies whether Popups should auto hide. |
final BooleanProperty |
consumeAutoHidingEvents |
Specifies whether the event, which caused the Popup to hide, should be consumed. |
final BooleanProperty |
hideOnEscape |
Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus. |
final ObjectProperty<EventHandler<Event>> |
onAutoHide |
Called after autoHide is run. |
final ReadOnlyObjectProperty<Node> |
ownerNode |
The node which is the owner of this popup. |
final ReadOnlyObjectProperty<Window> |
ownerWindow |
The window which is the parent of this popup. |
Properties declared in class javafx.stage.Window
eventDispatcher, focused, forceIntegerRenderScale, height, onCloseRequest, onHidden, onHiding, onShowing, onShown, opacity, outputScaleX, outputScaleY, renderScaleX, renderScaleY, scene, showing, width, x, y
Nested Class Summary
| Modifier and Type | Class | Description |
|---|---|---|
static enum |
PopupWindow.AnchorLocation |
Anchor location constants for popup anchor point selection. |
Constructor Summary
| Constructor | Description |
|---|---|
PopupWindow() |
Constructor for subclasses to call. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
final ObjectProperty<PopupWindow.AnchorLocation> |
anchorLocationProperty() |
Specifies the popup anchor point which is used in popup positioning. |
final ReadOnlyDoubleProperty |
anchorXProperty() |
Specifies the x coordinate of the popup anchor point on the screen. |
final ReadOnlyDoubleProperty |
anchorYProperty() |
Specifies the y coordinate of the popup anchor point on the screen. |
final BooleanProperty |
autoFixProperty() |
This convenience variable indicates whether, when the popup is shown, it should automatically correct its position such that it doesn't end up positioned off the screen. |
final BooleanProperty |
autoHideProperty() |
Specifies whether Popups should auto hide. |
final BooleanProperty |
consumeAutoHidingEventsProperty() |
Specifies whether the event, which caused the Popup to hide, should be consumed. |
final PopupWindow.AnchorLocation |
getAnchorLocation() |
Gets the value of the anchorLocation property. |
final double |
getAnchorX() |
Gets the value of the anchorX property. |
final double |
getAnchorY() |
Gets the value of the anchorY property. |
final boolean |
getConsumeAutoHidingEvents() |
Gets the value of the consumeAutoHidingEvents property. |
final EventHandler<Event> |
getOnAutoHide() |
Gets the value of the onAutoHide property. |
final Node |
getOwnerNode() |
Gets the value of the ownerNode property. |
final Window |
getOwnerWindow() |
Gets the value of the ownerWindow property. |
void |
hide() |
Hide this Popup and all its children |
final BooleanProperty |
hideOnEscapeProperty() |
Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus. |
final boolean |
isAutoFix() |
Gets the value of the autoFix property. |
final boolean |
isAutoHide() |
Gets the value of the autoHide property. |
final boolean |
isHideOnEscape() |
Gets the value of the hideOnEscape property. |
final ObjectProperty<EventHandler<Event>> |
onAutoHideProperty() |
Called after autoHide is run. |
final ReadOnlyObjectProperty<Node> |
ownerNodeProperty() |
The node which is the owner of this popup. |
final ReadOnlyObjectProperty<Window> |
ownerWindowProperty() |
The window which is the parent of this popup. |
final void |
setAnchorLocation |
Sets the value of the anchorLocation property. |
final void |
setAnchorX |
Sets the value of the anchorX property. |
final void |
setAnchorY |
Sets the value of the anchorY property. |
final void |
setAutoFix |
Sets the value of the autoFix property. |
final void |
setAutoHide |
Sets the value of the autoHide property. |
final void |
setConsumeAutoHidingEvents |
Sets the value of the consumeAutoHidingEvents property. |
final void |
setHideOnEscape |
Sets the value of the hideOnEscape property. |
final void |
setOnAutoHide |
Sets the value of the onAutoHide property. |
protected final void |
setScene |
Note to subclasses: the scene used by PopupWindow is very specifically managed by PopupWindow. |
void |
show |
Shows the popup at the specified location on the screen. |
void |
show |
Show the popup. |
void |
show |
Shows the popup at the specified location on the screen. |
Methods declared in class javafx.stage.Window
addEventFilter, addEventHandler, buildEventDispatchChain, centerOnScreen, eventDispatcherProperty, fireEvent, focusedProperty, forceIntegerRenderScaleProperty, getEventDispatcher, getHeight, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getOpacity, getOutputScaleX, getOutputScaleY, getProperties, getRenderScaleX, getRenderScaleY, getScene, getUserData, getWidth, getWindows, getX, getY, hasProperties, heightProperty, isFocused, isForceIntegerRenderScale, isShowing, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, outputScaleXProperty, outputScaleYProperty, removeEventFilter, removeEventHandler, renderScaleXProperty, renderScaleYProperty, requestFocus, sceneProperty, setEventDispatcher, setEventHandler, setForceIntegerRenderScale, setHeight, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setOpacity, setRenderScaleX, setRenderScaleY, setUserData, setWidth, setX, setY, show, showingProperty, sizeToScene, widthProperty, xProperty, yProperty
Property Details
ownerWindow
public final ReadOnlyObjectProperty<Window> ownerWindowProperty
- See Also:
ownerNode
public final ReadOnlyObjectProperty<Node> ownerNodeProperty
- See Also:
autoFix
public final BooleanProperty autoFixProperty
- Default value:
- true
- See Also:
autoHide
public final BooleanProperty autoHideProperty
The only exception is when owner Node is specified using show(javafx.scene.Node, double, double). Focusing owner Node will not hide the PopupWindow.
- Default value:
- false
- See Also:
onAutoHide
public final ObjectProperty<EventHandler<Event>> onAutoHideProperty
hideOnEscape
public final BooleanProperty hideOnEscapeProperty
- Default value:
- true
- See Also:
consumeAutoHidingEvents
public final BooleanProperty consumeAutoHidingEventsProperty
- Default value:
- true
- Since:
- JavaFX 2.2
- See Also:
anchorX
public final ReadOnlyDoubleProperty anchorXProperty
anchorLocation is set to WINDOW_TOP_LEFT or WINDOW_BOTTOM_LEFT the x and anchorX values will be identical.- Since:
- JavaFX 8.0
- See Also:
anchorY
public final ReadOnlyDoubleProperty anchorYProperty
anchorLocation is set to WINDOW_TOP_LEFT or WINDOW_TOP_RIGHT the y and anchorY values will be identical.- Since:
- JavaFX 8.0
- See Also:
anchorLocation
public final ObjectProperty<PopupWindow.AnchorLocation> anchorLocationProperty
In general changing of the anchor location won't change the current window position. Instead of that, the anchorX and anchorY values are recalculated to correspond to the new anchor point.
- Since:
- JavaFX 8.0
- See Also:
Constructor Details
PopupWindow
public PopupWindow()
Method Details
getOwnerWindow
public final Window getOwnerWindow()
ownerWindow property.- Property description:
- The window which is the parent of this popup. All popups must have an owner window.
- Returns:
- the value of the
ownerWindowproperty - See Also:
ownerWindowProperty
public final ReadOnlyObjectProperty<Window> ownerWindowProperty()
- Returns:
- the
ownerWindowproperty - See Also:
getOwnerNode
public final Node getOwnerNode()
ownerNode property.- Property description:
- The node which is the owner of this popup. All popups must have an owner window but are not required to be associated with an owner node. If an autohide Popup has an owner node, mouse press inside the owner node doesn't cause the Popup to hide.
- Returns:
- the value of the
ownerNodeproperty - See Also:
ownerNodeProperty
public final ReadOnlyObjectProperty<Node> ownerNodeProperty()
- Returns:
- the
ownerNodeproperty - See Also:
setScene
protected final void setScene(Scene scene)
- Overrides:
-
setScenein classWindow - Parameters:
-
scene- the scene to be rendered on this window - See Also:
setAutoFix
public final void setAutoFix(boolean value)
autoFix property.- Property description:
- This convenience variable indicates whether, when the popup is shown, it should automatically correct its position such that it doesn't end up positioned off the screen.
- Default value:
- true
- Parameters:
-
value- the value for theautoFixproperty - See Also:
isAutoFix
public final boolean isAutoFix()
autoFix property.- Property description:
- This convenience variable indicates whether, when the popup is shown, it should automatically correct its position such that it doesn't end up positioned off the screen.
- Default value:
- true
- Returns:
- the value of the
autoFixproperty - See Also:
autoFixProperty
public final BooleanProperty autoFixProperty()
- Default value:
- true
- Returns:
- the
autoFixproperty - See Also:
setAutoHide
public final void setAutoHide(boolean value)
autoHide property.- Property description:
- Specifies whether Popups should auto hide. If a popup loses focus and autoHide is true, then the popup will be hidden automatically.
The only exception is when owner Node is specified using
show(javafx.scene.Node, double, double). Focusing owner Node will not hide the PopupWindow. - Default value:
- false
- Parameters:
-
value- the value for theautoHideproperty - See Also:
isAutoHide
public final boolean isAutoHide()
autoHide property.- Property description:
- Specifies whether Popups should auto hide. If a popup loses focus and autoHide is true, then the popup will be hidden automatically.
The only exception is when owner Node is specified using
show(javafx.scene.Node, double, double). Focusing owner Node will not hide the PopupWindow. - Default value:
- false
- Returns:
- the value of the
autoHideproperty - See Also:
autoHideProperty
public final BooleanProperty autoHideProperty()
The only exception is when owner Node is specified using show(javafx.scene.Node, double, double). Focusing owner Node will not hide the PopupWindow.
- Default value:
- false
- Returns:
- the
autoHideproperty - See Also:
setOnAutoHide
public final void setOnAutoHide(EventHandler<Event> value)
onAutoHide property.- Property description:
- Called after autoHide is run.
- Parameters:
-
value- the value for theonAutoHideproperty - See Also:
getOnAutoHide
public final EventHandler<Event> getOnAutoHide()
onAutoHide property.- Property description:
- Called after autoHide is run.
- Returns:
- the value of the
onAutoHideproperty - See Also:
onAutoHideProperty
public final ObjectProperty<EventHandler<Event>> onAutoHideProperty()
- Returns:
- the
onAutoHideproperty - See Also:
setHideOnEscape
public final void setHideOnEscape(boolean value)
hideOnEscape property.- Property description:
- Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.
- Default value:
- true
- Parameters:
-
value- the value for thehideOnEscapeproperty - See Also:
isHideOnEscape
public final boolean isHideOnEscape()
hideOnEscape property.- Property description:
- Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.
- Default value:
- true
- Returns:
- the value of the
hideOnEscapeproperty - See Also:
hideOnEscapeProperty
public final BooleanProperty hideOnEscapeProperty()
- Default value:
- true
- Returns:
- the
hideOnEscapeproperty - See Also:
setConsumeAutoHidingEvents
public final void setConsumeAutoHidingEvents(boolean value)
consumeAutoHidingEvents property.- Property description:
- Specifies whether the event, which caused the Popup to hide, should be consumed. Having the event consumed prevents it from triggering some additional UI response in the Popup's owner window.
- Default value:
- true
- Parameters:
-
value- the value for theconsumeAutoHidingEventsproperty - Since:
- JavaFX 2.2
- See Also:
getConsumeAutoHidingEvents
public final boolean getConsumeAutoHidingEvents()
consumeAutoHidingEvents property.- Property description:
- Specifies whether the event, which caused the Popup to hide, should be consumed. Having the event consumed prevents it from triggering some additional UI response in the Popup's owner window.
- Default value:
- true
- Returns:
- the value of the
consumeAutoHidingEventsproperty - Since:
- JavaFX 2.2
- See Also:
consumeAutoHidingEventsProperty
public final BooleanProperty consumeAutoHidingEventsProperty()
- Default value:
- true
- Returns:
- the
consumeAutoHidingEventsproperty - Since:
- JavaFX 2.2
- See Also:
show
public void show(Window owner)
- Parameters:
-
owner- The owner of the popup. This must not be null. - Throws:
-
NullPointerException- if owner is null -
IllegalArgumentException- if the specified owner window would create cycle in the window hierarchy
show
public void show(Node ownerNode, double anchorX, double anchorY)
anchorLocation) is displayed at the specified anchorX and anchorY coordinates. The popup is associated with the specified owner node. The Window which contains the owner node at the time of the call becomes an owner window of the displayed popup.
Note that when autoHide is set to true, mouse press on the owner Node will not hide the PopupWindow.
- Parameters:
-
ownerNode- The owner Node of the popup. It must not be null and must be associated with a Window. -
anchorX- the x position of the popup anchor in screen coordinates -
anchorY- the y position of the popup anchor in screen coordinates - Throws:
-
NullPointerException- if ownerNode is null -
IllegalArgumentException- if the specified owner node is not associated with a Window or when the window would create cycle in the window hierarchy
show
public void show(Window ownerWindow, double anchorX, double anchorY)
anchorLocation) is displayed at the specified anchorX and anchorY coordinates.- Parameters:
-
ownerWindow- The owner of the popup. This must not be null. -
anchorX- the x position of the popup anchor in screen coordinates -
anchorY- the y position of the popup anchor in screen coordinates - Throws:
-
NullPointerException- if ownerWindow is null -
IllegalArgumentException- if the specified owner window would create cycle in the window hierarchy
hide
public void hide()
- Overrides:
-
hidein classWindow
setAnchorX
public final void setAnchorX(double value)
anchorX property.- Property description:
- Specifies the x coordinate of the popup anchor point on the screen. If the
anchorLocationis set toWINDOW_TOP_LEFTorWINDOW_BOTTOM_LEFTthexandanchorXvalues will be identical. - Parameters:
-
value- the value for theanchorXproperty - Since:
- JavaFX 8.0
- See Also:
getAnchorX
public final double getAnchorX()
anchorX property.- Property description:
- Specifies the x coordinate of the popup anchor point on the screen. If the
anchorLocationis set toWINDOW_TOP_LEFTorWINDOW_BOTTOM_LEFTthexandanchorXvalues will be identical. - Returns:
- the value of the
anchorXproperty - Since:
- JavaFX 8.0
- See Also:
anchorXProperty
public final ReadOnlyDoubleProperty anchorXProperty()
anchorLocation is set to WINDOW_TOP_LEFT or WINDOW_BOTTOM_LEFT the x and anchorX values will be identical.- Returns:
- the
anchorXproperty - Since:
- JavaFX 8.0
- See Also:
setAnchorY
public final void setAnchorY(double value)
anchorY property.- Property description:
- Specifies the y coordinate of the popup anchor point on the screen. If the
anchorLocationis set toWINDOW_TOP_LEFTorWINDOW_TOP_RIGHTtheyandanchorYvalues will be identical. - Parameters:
-
value- the value for theanchorYproperty - Since:
- JavaFX 8.0
- See Also:
getAnchorY
public final double getAnchorY()
anchorY property.- Property description:
- Specifies the y coordinate of the popup anchor point on the screen. If the
anchorLocationis set toWINDOW_TOP_LEFTorWINDOW_TOP_RIGHTtheyandanchorYvalues will be identical. - Returns:
- the value of the
anchorYproperty - Since:
- JavaFX 8.0
- See Also:
anchorYProperty
public final ReadOnlyDoubleProperty anchorYProperty()
anchorLocation is set to WINDOW_TOP_LEFT or WINDOW_TOP_RIGHT the y and anchorY values will be identical.- Returns:
- the
anchorYproperty - Since:
- JavaFX 8.0
- See Also:
setAnchorLocation
public final void setAnchorLocation(PopupWindow.AnchorLocation value)
anchorLocation property.- Property description:
- Specifies the popup anchor point which is used in popup positioning. The point can be set to a corner of the popup window or a corner of its content. In this context the content corners are derived from the popup root node's layout bounds.
In general changing of the anchor location won't change the current window position. Instead of that, the
anchorXandanchorYvalues are recalculated to correspond to the new anchor point. - Parameters:
-
value- the value for theanchorLocationproperty - Since:
- JavaFX 8.0
- See Also:
getAnchorLocation
public final PopupWindow.AnchorLocation getAnchorLocation()
anchorLocation property.- Property description:
- Specifies the popup anchor point which is used in popup positioning. The point can be set to a corner of the popup window or a corner of its content. In this context the content corners are derived from the popup root node's layout bounds.
In general changing of the anchor location won't change the current window position. Instead of that, the
anchorXandanchorYvalues are recalculated to correspond to the new anchor point. - Returns:
- the value of the
anchorLocationproperty - Since:
- JavaFX 8.0
- See Also:
anchorLocationProperty
public final ObjectProperty<PopupWindow.AnchorLocation> anchorLocationProperty()
In general changing of the anchor location won't change the current window position. Instead of that, the anchorX and anchorY values are recalculated to correspond to the new anchor point.
- Returns:
- the
anchorLocationproperty - Since:
- JavaFX 8.0
- See Also:
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.