- java.lang.Object
-
- javafx.stage.Window
-
- javafx.stage.PopupWindow
-
- All Implemented Interfaces:
EventTarget
- Direct Known Subclasses:
Popup
,PopupControl
public abstract class PopupWindow extends Window
PopupWindow is the parent for a variety of different types of popup based windows includingPopup
andTooltip
andContextMenu
.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
Properties Type Property Description ObjectProperty<PopupWindow.AnchorLocation>
anchorLocation
Specifies the popup anchor point which is used in popup positioning.ReadOnlyDoubleProperty
anchorX
Specifies the x coordinate of the popup anchor point on the screen.ReadOnlyDoubleProperty
anchorY
Specifies the y coordinate of the popup anchor point on the screen.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.BooleanProperty
autoHide
Specifies whether Popups should auto hide.BooleanProperty
consumeAutoHidingEvents
Specifies whether the event, which caused the Popup to hide, should be consumed.BooleanProperty
hideOnEscape
Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.ObjectProperty<EventHandler<Event>>
onAutoHide
Called after autoHide is run.ReadOnlyObjectProperty<Node>
ownerNode
The node which is the owner of this popup.ReadOnlyObjectProperty<Window>
ownerWindow
The window which is the parent of this popup.-
Properties inherited from 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
Nested Classes Modifier and Type Class Description static class
PopupWindow.AnchorLocation
Anchor location constants for popup anchor point selection.
-
Constructor Summary
Constructors Constructor Description PopupWindow()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectProperty<PopupWindow.AnchorLocation>
anchorLocationProperty()
Specifies the popup anchor point which is used in popup positioning.ReadOnlyDoubleProperty
anchorXProperty()
Specifies the x coordinate of the popup anchor point on the screen.ReadOnlyDoubleProperty
anchorYProperty()
Specifies the y coordinate of the popup anchor point on the screen.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.BooleanProperty
autoHideProperty()
Specifies whether Popups should auto hide.BooleanProperty
consumeAutoHidingEventsProperty()
Specifies whether the event, which caused the Popup to hide, should be consumed.PopupWindow.AnchorLocation
getAnchorLocation()
Gets the value of the property anchorLocation.double
getAnchorX()
Gets the value of the property anchorX.double
getAnchorY()
Gets the value of the property anchorY.boolean
getConsumeAutoHidingEvents()
Gets the value of the property consumeAutoHidingEvents.EventHandler<Event>
getOnAutoHide()
Gets the value of the property onAutoHide.Node
getOwnerNode()
Gets the value of the property ownerNode.Window
getOwnerWindow()
Gets the value of the property ownerWindow.void
hide()
Hide this Popup and all its childrenBooleanProperty
hideOnEscapeProperty()
Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.boolean
isAutoFix()
Gets the value of the property autoFix.boolean
isAutoHide()
Gets the value of the property autoHide.boolean
isHideOnEscape()
Gets the value of the property hideOnEscape.ObjectProperty<EventHandler<Event>>
onAutoHideProperty()
Called after autoHide is run.ReadOnlyObjectProperty<Node>
ownerNodeProperty()
The node which is the owner of this popup.ReadOnlyObjectProperty<Window>
ownerWindowProperty()
The window which is the parent of this popup.void
setAnchorLocation(PopupWindow.AnchorLocation value)
Sets the value of the property anchorLocation.void
setAnchorX(double value)
Sets the value of the property anchorX.void
setAnchorY(double value)
Sets the value of the property anchorY.void
setAutoFix(boolean value)
Sets the value of the property autoFix.void
setAutoHide(boolean value)
Sets the value of the property autoHide.void
setConsumeAutoHidingEvents(boolean value)
Sets the value of the property consumeAutoHidingEvents.void
setHideOnEscape(boolean value)
Sets the value of the property hideOnEscape.void
setOnAutoHide(EventHandler<Event> value)
Sets the value of the property onAutoHide.protected void
setScene(Scene scene)
Note to subclasses: the scene used by PopupWindow is very specifically managed by PopupWindow.void
show(Node ownerNode, double anchorX, double anchorY)
Shows the popup at the specified location on the screen.void
show(Window owner)
Show the popup.void
show(Window ownerWindow, double anchorX, double anchorY)
Shows the popup at the specified location on the screen.-
Methods inherited from 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 Detail
-
ownerWindow
public final ReadOnlyObjectProperty<Window> ownerWindowProperty
The window which is the parent of this popup. All popups must have an owner window.- See Also:
getOwnerWindow()
-
ownerNode
public final ReadOnlyObjectProperty<Node> ownerNodeProperty
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.- See Also:
getOwnerNode()
-
autoFix
public 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.- Default value:
- true
- See Also:
isAutoFix()
,setAutoFix(boolean)
-
autoHide
public final BooleanProperty autoHideProperty
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
- See Also:
isAutoHide()
,setAutoHide(boolean)
-
onAutoHide
public final ObjectProperty<EventHandler<Event>> onAutoHideProperty
Called after autoHide is run.- See Also:
getOnAutoHide()
,setOnAutoHide(EventHandler)
-
hideOnEscape
public final BooleanProperty hideOnEscapeProperty
Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.- Default value:
- true
- See Also:
isHideOnEscape()
,setHideOnEscape(boolean)
-
consumeAutoHidingEvents
public final BooleanProperty consumeAutoHidingEventsProperty
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
- Since:
- JavaFX 2.2
- See Also:
getConsumeAutoHidingEvents()
,setConsumeAutoHidingEvents(boolean)
-
anchorX
public final ReadOnlyDoubleProperty anchorXProperty
Specifies the x coordinate of the popup anchor point on the screen. If theanchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_BOTTOM_LEFT
thex
andanchorX
values will be identical.- Since:
- JavaFX 8.0
- See Also:
getAnchorX()
,setAnchorX(double)
-
anchorY
public final ReadOnlyDoubleProperty anchorYProperty
Specifies the y coordinate of the popup anchor point on the screen. If theanchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_TOP_RIGHT
they
andanchorY
values will be identical.- Since:
- JavaFX 8.0
- See Also:
getAnchorY()
,setAnchorY(double)
-
anchorLocation
public final ObjectProperty<PopupWindow.AnchorLocation> anchorLocationProperty
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
anchorX
andanchorY
values are recalculated to correspond to the new anchor point.- Since:
- JavaFX 8.0
- See Also:
getAnchorLocation()
,setAnchorLocation(PopupWindow.AnchorLocation)
-
-
Method Detail
-
getOwnerWindow
public final Window getOwnerWindow()
Gets the value of the property ownerWindow.- Property description:
- The window which is the parent of this popup. All popups must have an owner window.
-
ownerWindowProperty
public final ReadOnlyObjectProperty<Window> ownerWindowProperty()
The window which is the parent of this popup. All popups must have an owner window.- See Also:
getOwnerWindow()
-
getOwnerNode
public final Node getOwnerNode()
Gets the value of the property ownerNode.- 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.
-
ownerNodeProperty
public final ReadOnlyObjectProperty<Node> ownerNodeProperty()
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.- See Also:
getOwnerNode()
-
setScene
protected final void setScene(Scene scene)
Note to subclasses: the scene used by PopupWindow is very specifically managed by PopupWindow. This method is overridden to throw UnsupportedOperationException. You cannot specify your own scene.
-
setAutoFix
public final void setAutoFix(boolean value)
Sets the value of the property autoFix.- 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
-
isAutoFix
public final boolean isAutoFix()
Gets the value of the property autoFix.- 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
-
autoFixProperty
public 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.- Default value:
- true
- See Also:
isAutoFix()
,setAutoFix(boolean)
-
setAutoHide
public final void setAutoHide(boolean value)
Sets the value of the property autoHide.- 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
-
isAutoHide
public final boolean isAutoHide()
Gets the value of the property autoHide.- 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
-
autoHideProperty
public final BooleanProperty autoHideProperty()
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
- See Also:
isAutoHide()
,setAutoHide(boolean)
-
setOnAutoHide
public final void setOnAutoHide(EventHandler<Event> value)
Sets the value of the property onAutoHide.- Property description:
- Called after autoHide is run.
-
getOnAutoHide
public final EventHandler<Event> getOnAutoHide()
Gets the value of the property onAutoHide.- Property description:
- Called after autoHide is run.
-
onAutoHideProperty
public final ObjectProperty<EventHandler<Event>> onAutoHideProperty()
Called after autoHide is run.- See Also:
getOnAutoHide()
,setOnAutoHide(EventHandler)
-
setHideOnEscape
public final void setHideOnEscape(boolean value)
Sets the value of the property hideOnEscape.- Property description:
- Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.
- Default value:
- true
-
isHideOnEscape
public final boolean isHideOnEscape()
Gets the value of the property hideOnEscape.- Property description:
- Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.
- Default value:
- true
-
hideOnEscapeProperty
public final BooleanProperty hideOnEscapeProperty()
Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.- Default value:
- true
- See Also:
isHideOnEscape()
,setHideOnEscape(boolean)
-
setConsumeAutoHidingEvents
public final void setConsumeAutoHidingEvents(boolean value)
Sets the value of the property consumeAutoHidingEvents.- 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
- Since:
- JavaFX 2.2
-
getConsumeAutoHidingEvents
public final boolean getConsumeAutoHidingEvents()
Gets the value of the property consumeAutoHidingEvents.- 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
- Since:
- JavaFX 2.2
-
consumeAutoHidingEventsProperty
public final BooleanProperty consumeAutoHidingEventsProperty()
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
- Since:
- JavaFX 2.2
- See Also:
getConsumeAutoHidingEvents()
,setConsumeAutoHidingEvents(boolean)
-
show
public void show(Window owner)
Show the popup.- Parameters:
owner
- The owner of the popup. This must not be null.- Throws:
NullPointerException
- if owner is nullIllegalArgumentException
- if the specified owner window would create cycle in the window hierarchy
-
show
public void show(Node ownerNode, double anchorX, double anchorY)
Shows the popup at the specified location on the screen. The popup window is positioned in such way that its anchor point (anchorLocation
) is displayed at the specifiedanchorX
andanchorY
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 coordinatesanchorY
- the y position of the popup anchor in screen coordinates- Throws:
NullPointerException
- if ownerNode is nullIllegalArgumentException
- 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)
Shows the popup at the specified location on the screen. The popup window is positioned in such way that its anchor point (anchorLocation
) is displayed at the specifiedanchorX
andanchorY
coordinates.- Parameters:
ownerWindow
- The owner of the popup. This must not be null.anchorX
- the x position of the popup anchor in screen coordinatesanchorY
- the y position of the popup anchor in screen coordinates- Throws:
NullPointerException
- if ownerWindow is nullIllegalArgumentException
- if the specified owner window would create cycle in the window hierarchy
-
setAnchorX
public final void setAnchorX(double value)
Sets the value of the property anchorX.- Property description:
- Specifies the x coordinate of the popup anchor point on the screen. If
the
anchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_BOTTOM_LEFT
thex
andanchorX
values will be identical. - Since:
- JavaFX 8.0
-
getAnchorX
public final double getAnchorX()
Gets the value of the property anchorX.- Property description:
- Specifies the x coordinate of the popup anchor point on the screen. If
the
anchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_BOTTOM_LEFT
thex
andanchorX
values will be identical. - Since:
- JavaFX 8.0
-
anchorXProperty
public final ReadOnlyDoubleProperty anchorXProperty()
Specifies the x coordinate of the popup anchor point on the screen. If theanchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_BOTTOM_LEFT
thex
andanchorX
values will be identical.- Since:
- JavaFX 8.0
- See Also:
getAnchorX()
,setAnchorX(double)
-
setAnchorY
public final void setAnchorY(double value)
Sets the value of the property anchorY.- Property description:
- Specifies the y coordinate of the popup anchor point on the screen. If
the
anchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_TOP_RIGHT
they
andanchorY
values will be identical. - Since:
- JavaFX 8.0
-
getAnchorY
public final double getAnchorY()
Gets the value of the property anchorY.- Property description:
- Specifies the y coordinate of the popup anchor point on the screen. If
the
anchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_TOP_RIGHT
they
andanchorY
values will be identical. - Since:
- JavaFX 8.0
-
anchorYProperty
public final ReadOnlyDoubleProperty anchorYProperty()
Specifies the y coordinate of the popup anchor point on the screen. If theanchorLocation
is set toWINDOW_TOP_LEFT
orWINDOW_TOP_RIGHT
they
andanchorY
values will be identical.- Since:
- JavaFX 8.0
- See Also:
getAnchorY()
,setAnchorY(double)
-
setAnchorLocation
public final void setAnchorLocation(PopupWindow.AnchorLocation value)
Sets the value of the property anchorLocation.- 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
anchorX
andanchorY
values are recalculated to correspond to the new anchor point. - Since:
- JavaFX 8.0
-
getAnchorLocation
public final PopupWindow.AnchorLocation getAnchorLocation()
Gets the value of the property anchorLocation.- 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
anchorX
andanchorY
values are recalculated to correspond to the new anchor point. - Since:
- JavaFX 8.0
-
anchorLocationProperty
public final ObjectProperty<PopupWindow.AnchorLocation> anchorLocationProperty()
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
anchorX
andanchorY
values are recalculated to correspond to the new anchor point.- Since:
- JavaFX 8.0
- See Also:
getAnchorLocation()
,setAnchorLocation(PopupWindow.AnchorLocation)
-
-