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.
Type | Property and 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.
|
Modifier and Type | Class and Description |
---|---|
static class |
PopupWindow.AnchorLocation
Anchor location constants for popup anchor point selection.
|
Constructor and Description |
---|
PopupWindow() |
Modifier and Type | Method and 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 children
|
BooleanProperty |
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.
|
addEventFilter, addEventHandler, buildEventDispatchChain, centerOnScreen, eventDispatcherProperty, fireEvent, focusedProperty, getEventDispatcher, getHeight, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getOpacity, getProperties, getScene, getUserData, getWidth, getX, getY, hasProperties, heightProperty, isFocused, isShowing, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, removeEventFilter, removeEventHandler, requestFocus, sceneProperty, setEventDispatcher, setEventHandler, setHeight, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setOpacity, setUserData, setWidth, setX, setY, show, showingProperty, sizeToScene, widthProperty, xProperty, yProperty
public final ReadOnlyObjectProperty<Window> ownerWindowProperty
getOwnerWindow()
public final ReadOnlyObjectProperty<Node> ownerNodeProperty
getOwnerNode()
public final BooleanProperty autoFixProperty
isAutoFix()
,
setAutoFix(boolean)
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.
isAutoHide()
,
setAutoHide(boolean)
public final ObjectProperty<EventHandler<Event>> onAutoHideProperty
getOnAutoHide()
,
setOnAutoHide(EventHandler)
public final BooleanProperty hideOnEscapeProperty
isHideOnEscape()
,
setHideOnEscape(boolean)
public final BooleanProperty consumeAutoHidingEventsProperty
getConsumeAutoHidingEvents()
,
setConsumeAutoHidingEvents(boolean)
public final ReadOnlyDoubleProperty anchorXProperty
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_BOTTOM_LEFT
the x
and anchorX
values will
be identical.getAnchorX()
,
setAnchorX(double)
public final ReadOnlyDoubleProperty anchorYProperty
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_TOP_RIGHT
the y
and anchorY
values will
be identical.getAnchorY()
,
setAnchorY(double)
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.
getAnchorLocation()
,
setAnchorLocation(AnchorLocation)
public final Window getOwnerWindow()
public final ReadOnlyObjectProperty<Window> ownerWindowProperty()
getOwnerWindow()
public final Node getOwnerNode()
public final ReadOnlyObjectProperty<Node> ownerNodeProperty()
getOwnerNode()
protected final void setScene(Scene scene)
public final void setAutoFix(boolean value)
public final boolean isAutoFix()
public final BooleanProperty autoFixProperty()
isAutoFix()
,
setAutoFix(boolean)
public final void setAutoHide(boolean value)
The only exception is when owner Node is specified using show(javafx.scene.Node, double, double)
.
Focusing owner Node will not hide the PopupWindow.
public final boolean isAutoHide()
The only exception is when owner Node is specified using show(javafx.scene.Node, double, double)
.
Focusing owner Node will not hide the PopupWindow.
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.
isAutoHide()
,
setAutoHide(boolean)
public final void setOnAutoHide(EventHandler<Event> value)
public final EventHandler<Event> getOnAutoHide()
public final ObjectProperty<EventHandler<Event>> onAutoHideProperty()
getOnAutoHide()
,
setOnAutoHide(EventHandler)
public final void setHideOnEscape(boolean value)
public final boolean isHideOnEscape()
public final BooleanProperty hideOnEscapeProperty()
isHideOnEscape()
,
setHideOnEscape(boolean)
public final void setConsumeAutoHidingEvents(boolean value)
public final boolean getConsumeAutoHidingEvents()
public final BooleanProperty consumeAutoHidingEventsProperty()
getConsumeAutoHidingEvents()
,
setConsumeAutoHidingEvents(boolean)
public void show(Window owner)
owner
- The owner of the popup. This must not be null.NullPointerException
- if owner is nullIllegalArgumentException
- if the specified owner window would
create cycle in the window hierarchypublic 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 autoHideProperty()
is set to true, mouse press on the owner Node
will not hide the PopupWindow.
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 coordinatesNullPointerException
- 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 hierarchypublic void show(Window ownerWindow, double anchorX, double anchorY)
anchorLocation
)
is displayed at the specified anchorX
and anchorY
coordinates.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 coordinatesNullPointerException
- if ownerWindow is nullIllegalArgumentException
- if the specified owner window would
create cycle in the window hierarchypublic final void setAnchorX(double value)
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_BOTTOM_LEFT
the x
and anchorX
values will
be identical.public final double getAnchorX()
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_BOTTOM_LEFT
the x
and anchorX
values will
be identical.public final ReadOnlyDoubleProperty anchorXProperty()
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_BOTTOM_LEFT
the x
and anchorX
values will
be identical.getAnchorX()
,
setAnchorX(double)
public final void setAnchorY(double value)
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_TOP_RIGHT
the y
and anchorY
values will
be identical.public final double getAnchorY()
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_TOP_RIGHT
the y
and anchorY
values will
be identical.public final ReadOnlyDoubleProperty anchorYProperty()
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_TOP_RIGHT
the y
and anchorY
values will
be identical.getAnchorY()
,
setAnchorY(double)
public final void setAnchorLocation(PopupWindow.AnchorLocation value)
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.
public final PopupWindow.AnchorLocation getAnchorLocation()
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.
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.
getAnchorLocation()
,
setAnchorLocation(AnchorLocation)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.