public abstract class PopupWindow extends Window
Popup
and javafx.scene.control.Tooltip
and javafx.scene.control.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 |
---|---|
<any> |
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.
|
<any> |
onAutoHide
Called after autoHide is run.
|
<any> |
ownerNode
The node which is the owner of this popup.
|
<any> |
ownerWindow
The window which is the parent of this popup.
|
eventDispatcherProperty, focusedProperty, forceIntegerRenderScaleProperty, heightProperty, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, outputScaleXProperty, outputScaleYProperty, renderScaleXProperty, renderScaleYProperty, sceneProperty, showingProperty, widthProperty, xProperty, yProperty
Modifier and Type | Class and Description |
---|---|
static class |
PopupWindow.AnchorLocation
Anchor location constants for popup anchor point selection.
|
(package private) static class |
PopupWindow.PopupEventRedirector |
Modifier and Type | Field and Description |
---|---|
private <any> |
anchorLocation
Specifies the popup anchor point which is used in popup positioning.
|
private ReadOnlyDoubleWrapper |
anchorX
Specifies the x coordinate of the popup anchor point on the screen.
|
private ReadOnlyDoubleWrapper |
anchorY
Specifies the y coordinate of the popup anchor point on the screen.
|
private 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.
|
private boolean |
autofixActive |
private BooleanProperty |
autoHide
Specifies whether Popups should auto hide.
|
private boolean |
autohideActive |
private Bounds |
cachedAnchorBounds |
private Bounds |
cachedExtendedBounds |
private <any> |
changeListener
RT-28454: When a parent node or parent window we are associated with is not
visible anymore, possibly because the scene was not valid anymore, we should hide.
|
private java.util.List<PopupWindow> |
children
A private list of all child popups.
|
private BooleanProperty |
consumeAutoHidingEvents
Specifies whether the event, which caused the Popup to hide, should be
consumed.
|
private BooleanProperty |
hideOnEscape
Specifies whether the PopupWindow should be hidden when an unhandled escape key
is pressed while the popup has focus.
|
private <any> |
onAutoHide
Called after autoHide is run.
|
private <any> |
ownerFocusedListener |
private <any> |
ownerNode
The node which is the owner of this popup.
|
private <any> |
ownerWindow
The window which is the parent of this popup.
|
private InvalidationListener |
popupWindowUpdater
Keeps track of the bounds of the content, and adjust the position and
size of the popup window accordingly.
|
private Window |
rootWindow |
private <any> |
weakOwnerNodeListener |
acc, hasBeenVisible
Constructor and Description |
---|
PopupWindow() |
Modifier and Type | Method and Description |
---|---|
<any> |
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.
|
private void |
bindOwnerFocusedProperty(Window ownerWindowValue) |
BooleanProperty |
consumeAutoHidingEventsProperty()
Specifies whether the event, which caused the Popup to hide, should be
consumed.
|
(package private) WindowEventDispatcher |
createInternalEventDispatcher() |
(package private) void |
doAutoHide() |
private void |
doVisibleChanged(boolean visible) |
private void |
doVisibleChanging(boolean visible) |
private Bounds |
getAnchorBounds() |
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.
|
(package private) <any> |
getContent() |
private Bounds |
getExtendedBounds() |
<any> |
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.
|
private static Window |
getRootWindow(Window win)
Gets the root (non PopupWindow) Window for the provided window.
|
(package private) Window |
getWindowOwner() |
private void |
handleAutofixActivation(boolean visible,
boolean autofix) |
private void |
handleAutohideActivation(boolean visible,
boolean autohide) |
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.
|
(package private) void |
notifyLocationChanged(double newX,
double newY)
Notification from the windowing system that the window's position has
changed.
|
<any> |
onAutoHideProperty()
Called after autoHide is run.
|
<any> |
ownerNodeProperty()
The node which is the owner of this popup.
|
<any> |
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(<any> 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.
|
(package private) void |
setXInternal(double value) |
(package private) void |
setYInternal(double value) |
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.
|
private void |
showImpl(Window owner) |
private void |
startMonitorOwnerEvents(Window ownerWindowValue) |
private void |
stopMonitorOwnerEvents(Window ownerWindowValue) |
private void |
unbindOwnerFocusedProperty(Window ownerWindowValue) |
private Bounds |
union(Bounds bounds1,
Bounds bounds2) |
private void |
updateWindow(double newAnchorX,
double newAnchorY) |
private void |
validateOwnerWindow(Window owner) |
private double |
windowToAnchorX(double windowX) |
private double |
windowToAnchorY(double windowY) |
private static boolean |
wouldCreateCycle(Window parent,
Window child) |
addEventFilter, addEventHandler, applyBounds, buildEventDispatchChain, centerOnScreen, decreaseFocusGrabCounter, eventDispatcherProperty, fireEvent, focusedProperty, forceIntegerRenderScaleProperty, getEventDispatcher, getHeight, getInternalEventDispatcher, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getOpacity, getOutputScaleX, getOutputScaleY, getPeer, getPeerListener, getProperties, getRenderScaleX, getRenderScaleY, getScene, getUserData, getWidth, getWindows, getX, getY, hasProperties, heightProperty, increaseFocusGrabCounter, isFocused, isForceIntegerRenderScale, isShowing, notifySizeChanged, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, outputScaleXProperty, outputScaleYProperty, removeEventFilter, removeEventHandler, renderScaleXProperty, renderScaleYProperty, requestFocus, sceneProperty, setEventDispatcher, setEventHandler, setFocused, setForceIntegerRenderScale, setHeight, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setOpacity, setPeer, setPeerListener, setRenderScaleX, setRenderScaleY, setUserData, setWidth, setX, setY, show, showingProperty, sizeToScene, updateRenderScales, widthProperty, xProperty, yProperty
public final <any> ownerWindowProperty
getOwnerWindow()
public final <any> 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 <any> onAutoHideProperty
getOnAutoHide()
,
#setOnAutoHide()
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 <any> 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)
private final java.util.List<PopupWindow> children
private final InvalidationListener popupWindowUpdater
private <any> changeListener
private <any> weakOwnerNodeListener
private <any> ownerWindow
private <any> ownerNode
private BooleanProperty autoFix
private BooleanProperty autoHide
The only exception is when owner Node is specified using #show(javafx.scene.Node, double, double)
.
Focusing owner Node will not hide the PopupWindow.
private <any> onAutoHide
private BooleanProperty hideOnEscape
private BooleanProperty consumeAutoHidingEvents
private Window rootWindow
private final ReadOnlyDoubleWrapper anchorX
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_BOTTOM_LEFT
the x
and anchorX
values will
be identical.private final ReadOnlyDoubleWrapper anchorY
anchorLocation
is set to WINDOW_TOP_LEFT
or
WINDOW_TOP_RIGHT
the y
and anchorY
values will
be identical.private final <any> anchorLocation
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.
private Bounds cachedExtendedBounds
private Bounds cachedAnchorBounds
private <any> ownerFocusedListener
private boolean autofixActive
private boolean autohideActive
<any> getContent()
public final Window getOwnerWindow()
public final <any> ownerWindowProperty()
getOwnerWindow()
public final Node getOwnerNode()
public final <any> 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)
public final boolean isAutoHide()
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(<any> value)
public final <any> getOnAutoHide()
public final <any> onAutoHideProperty()
getOnAutoHide()
,
#setOnAutoHide()
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.java.lang.NullPointerException
- if owner is nulljava.lang.IllegalArgumentException
- 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 autoHide
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 coordinatesjava.lang.NullPointerException
- if ownerNode is nulljava.lang.IllegalArgumentException
- if the specified owner node is not
associated with a Window or when the window would create cycle
in the window hierarchyprivate void showImpl(Window owner)
private void doVisibleChanging(boolean visible)
private void doVisibleChanged(boolean visible)
public final void setAnchorX(double value)
public final double getAnchorX()
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)
public final double getAnchorY()
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)
public final PopupWindow.AnchorLocation getAnchorLocation()
public final <any> 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)
void setXInternal(double value)
setXInternal
in class Window
void setYInternal(double value)
setYInternal
in class Window
void notifyLocationChanged(double newX, double newY)
Window
notifyLocationChanged
in class Window
newX
- the new window x positionnewY
- the new window y positionprivate Bounds getExtendedBounds()
private Bounds getAnchorBounds()
private void updateWindow(double newAnchorX, double newAnchorY)
private Bounds union(Bounds bounds1, Bounds bounds2)
private double windowToAnchorX(double windowX)
private double windowToAnchorY(double windowY)
private static Window getRootWindow(Window win)
win
- the Window for which to get the root windowvoid doAutoHide()
WindowEventDispatcher createInternalEventDispatcher()
createInternalEventDispatcher
in class Window
Window getWindowOwner()
getWindowOwner
in class Window
private void startMonitorOwnerEvents(Window ownerWindowValue)
private void stopMonitorOwnerEvents(Window ownerWindowValue)
private void bindOwnerFocusedProperty(Window ownerWindowValue)
private void unbindOwnerFocusedProperty(Window ownerWindowValue)
private void handleAutofixActivation(boolean visible, boolean autofix)
private void handleAutohideActivation(boolean visible, boolean autohide)
private void validateOwnerWindow(Window owner)