java.lang.Object
javafx.stage.Window
javafx.stage.PopupWindow
javafx.scene.control.PopupControl
atlantafx.base.controls.Popover
- All Implemented Interfaces:
javafx.css.Styleable,javafx.event.EventTarget,javafx.scene.control.Skinnable
public class Popover
extends javafx.scene.control.PopupControl
A control that is intended to provide detailed information about
an owning node in a popup window. The popup window has a lightweight
appearance (no default window decorations) and an arrow pointing at the owner.
Due to the nature of popup windows the Popover will move around with the parent
window when the user drags it.
The Popover can be detached from the owning node by dragging it away from the owner. It stops displaying an arrow and starts displaying a title and a close icon.
Example
var textFlow = new TextFlow(new Text("Some content"));
textFlow.setPrefWidth(300);
var popover = new Popover(textFlow);
popover.setTitle("Title");
var ownerLink = new Hyperlink("Show popover");
ownerLink.setOnAction(e -> popover.show(ownerLink));
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javafx.scene.control.PopupControl
javafx.scene.control.PopupControl.CSSBridgeNested classes/interfaces inherited from class javafx.stage.PopupWindow
javafx.stage.PopupWindow.AnchorLocation -
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.BooleanPropertyStores the "animated" flag.final javafx.beans.property.DoublePropertyControls the distance between the arrow and the corners of the popover.final javafx.beans.property.ObjectProperty<Popover.ArrowLocation> Stores the preferred arrow location.final javafx.beans.property.DoublePropertyControls the size of the arrow.final javafx.beans.property.BooleanPropertyDetermines whether the header's close button should be available or not.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Specifies the content shown by the popover.final javafx.beans.property.DoublePropertyReturns the corner radius property for the popover.final javafx.beans.property.BooleanPropertyDetermines if the popover is detachable at all.final javafx.beans.property.BooleanPropertyDetermines whether the popover is detached from the owning node or not.final javafx.beans.property.ObjectProperty<javafx.util.Duration> Stores the fade-in duration.final javafx.beans.property.ObjectProperty<javafx.util.Duration> Stores the fade-out duration.final javafx.beans.property.BooleanPropertyDetermines whether thePopoverheader should remain visible or not, even while attached.final javafx.beans.property.StringPropertyStores the title to display in the Popover's header.Properties inherited from class javafx.scene.control.PopupControl
id, maxHeight, maxWidth, minHeight, minWidth, prefHeight, prefWidth, skin, styleProperties inherited from class javafx.stage.PopupWindow
anchorLocation, anchorX, anchorY, autoFix, autoHide, consumeAutoHidingEvents, hideOnEscape, onAutoHide, ownerNode, ownerWindowProperties 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 -
Field Summary
Fields inherited from class javafx.scene.control.PopupControl
bridge, USE_COMPUTED_SIZE, USE_PREF_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal javafx.beans.property.BooleanPropertyStores the "animated" flag.final javafx.beans.property.DoublePropertyControls the distance between the arrow and the corners of the popover.final javafx.beans.property.ObjectProperty<Popover.ArrowLocation> Stores the preferred arrow location.final javafx.beans.property.DoublePropertyControls the size of the arrow.final javafx.beans.property.BooleanPropertyDetermines whether the header's close button should be available or not.final javafx.beans.property.ObjectProperty<javafx.scene.Node> Specifies the content shown by the popover.final javafx.beans.property.DoublePropertyReturns the corner radius property for the popover.protected javafx.scene.control.Skin<?> final voiddetach()Detaches the popover from the owning node.final javafx.beans.property.BooleanPropertyDetermines if the popover is detachable at all.final javafx.beans.property.BooleanPropertyDetermines whether the popover is detached from the owning node or not.final javafx.beans.property.ObjectProperty<javafx.util.Duration> Stores the fade-in duration.final javafx.beans.property.ObjectProperty<javafx.util.Duration> Stores the fade-out duration.final doubleReturns the value of the arrow indent property.final Popover.ArrowLocationReturns the value of the arrow location property.final doubleReturns the value of the arrow size property.final javafx.scene.NodeReturns the value of the content property.final doubleReturns the value of the corner radius property.final javafx.util.DurationReturns the value of the fade-in duration property.final javafx.util.DurationReturns the value of the fade-out duration property.final javafx.scene.layout.StackPanegetRoot()The root pane stores the content node of the popover.final StringgetTitle()Returns the value of the title property.final javafx.beans.property.BooleanPropertyDetermines whether thePopoverheader should remain visible or not, even while attached.final voidhide()Hides the popover by quickly changing its opacity to 0.final voidhide(javafx.util.Duration fadeOutDuration) Hides the popover by quickly changing its opacity to 0.final booleanReturns the value of the "animated" property.final booleanReturns the value of the closeButtonEnabled property.final booleanReturns the value of the detachable property.final booleanReturns the value of the detached property.final booleanReturns the value of the detachable property.final voidsetAnimated(boolean animated) Sets the value of the "animated" property.final voidsetArrowIndent(double size) Sets the value of the arrow indent property.final voidsetArrowLocation(Popover.ArrowLocation location) Sets the value of the arrow location property.final voidsetArrowSize(double size) Sets the value of the arrow size property.final voidsetCloseButtonEnabled(boolean enabled) Sets the value of the closeButtonEnabled property.final voidsetContentNode(javafx.scene.Node content) Sets the value of the content property.final voidsetCornerRadius(double radius) Sets the value of the corner radius property.final voidsetDetachable(boolean detachable) Sets the value of the detachable property.final voidsetDetached(boolean detached) Sets the value of the detached property.final voidsetFadeInDuration(javafx.util.Duration duration) Sets the value of the fade-in duration property.final voidsetFadeOutDuration(javafx.util.Duration duration) Sets the value of the fade-out duration property.final voidsetHeaderAlwaysVisible(boolean visible) Sets the value of the headerAlwaysVisible property.final voidSets the value of the title property.final voidshow(javafx.scene.Node owner) Shows the popover in a position relative to the edges of the given owner node.final voidshow(javafx.scene.Node owner, double offset) Shows the popover in a position relative to the edges of the given owner node.final voidshow(javafx.scene.Node owner, double x, double y) Makes the popover visible at the give location and associates it with the given owner node.final voidshow(javafx.scene.Node owner, double x, double y, javafx.util.Duration fadeInDuration) Makes the popover visible at the give location and associates it with the given owner node.final voidshow(javafx.stage.Window owner) final voidshow(javafx.stage.Window ownerWindow, double anchorX, double anchorY) final javafx.beans.property.StringPropertyStores the title to display in the Popover's header.Methods inherited from class javafx.scene.control.PopupControl
getClassCssMetaData, getCssMetaData, getId, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, getPseudoClassStates, getSkin, getStyle, getStyleableNode, getStyleableParent, getStyleClass, getTypeSelector, idProperty, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, pseudoClassStateChanged, setId, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setPrefHeight, setPrefSize, setPrefWidth, setSkin, setStyle, skinProperty, stylePropertyMethods inherited from class javafx.stage.PopupWindow
anchorLocationProperty, anchorXProperty, anchorYProperty, autoFixProperty, autoHideProperty, consumeAutoHidingEventsProperty, getAnchorLocation, getAnchorX, getAnchorY, getConsumeAutoHidingEvents, getOnAutoHide, getOwnerNode, getOwnerWindow, hideOnEscapeProperty, isAutoFix, isAutoHide, isHideOnEscape, onAutoHideProperty, ownerNodeProperty, ownerWindowProperty, setAnchorLocation, setAnchorX, setAnchorY, setAutoFix, setAutoHide, setConsumeAutoHidingEvents, setHideOnEscape, setOnAutoHide, setSceneMethods 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 Details
-
contentNode
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> contentNodePropertySpecifies the content shown by the popover.- See Also:
-
headerAlwaysVisible
public final javafx.beans.property.BooleanProperty headerAlwaysVisiblePropertyDetermines whether thePopoverheader should remain visible or not, even while attached.- See Also:
-
closeButtonEnabled
public final javafx.beans.property.BooleanProperty closeButtonEnabledPropertyDetermines whether the header's close button should be available or not.- See Also:
-
detachable
public final javafx.beans.property.BooleanProperty detachablePropertyDetermines if the popover is detachable at all.- See Also:
-
detached
public final javafx.beans.property.BooleanProperty detachedPropertyDetermines whether the popover is detached from the owning node or not. A detached popover no longer shows an arrow pointing at the owner and features its own title bar.- See Also:
-
arrowSize
public final javafx.beans.property.DoubleProperty arrowSizePropertyControls the size of the arrow. Default value is "12".- See Also:
-
arrowIndent
public final javafx.beans.property.DoubleProperty arrowIndentPropertyControls the distance between the arrow and the corners of the popover. Default value is "12".- See Also:
-
cornerRadius
public final javafx.beans.property.DoubleProperty cornerRadiusPropertyReturns the corner radius property for the popover. Default value is "6".- See Also:
-
title
public final javafx.beans.property.StringProperty titlePropertyStores the title to display in the Popover's header.- See Also:
-
arrowLocation
Stores the preferred arrow location. This might not be the actual location of the arrow if auto fix is enabled.- See Also:
-
fadeInDuration
public final javafx.beans.property.ObjectProperty<javafx.util.Duration> fadeInDurationPropertyStores the fade-in duration. This should be set before callingPopover.show(..).- See Also:
-
fadeOutDuration
public final javafx.beans.property.ObjectProperty<javafx.util.Duration> fadeOutDurationPropertyStores the fade-out duration.- See Also:
-
animated
public final javafx.beans.property.BooleanProperty animatedPropertyStores the "animated" flag. If true then the Popover will be shown / hidden with a short fade in / out animation.- See Also:
-
-
Constructor Details
-
Popover
public Popover()Creates a popover with a label as the content node. -
Popover
public Popover(javafx.scene.Node content) Creates a popover with the given node as the content node.- Parameters:
content- The content shown by the popover.
-
-
Method Details
-
createDefaultSkin
protected javafx.scene.control.Skin<?> createDefaultSkin()- Overrides:
createDefaultSkinin classjavafx.scene.control.PopupControl
-
getRoot
public final javafx.scene.layout.StackPane getRoot()The root pane stores the content node of the popover. It is accessible via this method in order to support proper styling.Example:
Popover popOver = new Popover(); popOver.getRoot().getStylesheets().add(...);- Returns:
- the root pane
-
show
public final void show(javafx.scene.Node owner) Shows the popover in a position relative to the edges of the given owner node. The position is dependent on the arrow location. If the arrow is pointing to the right then the popover will be placed to the left of the given owner. If the arrow points up then the popover will be placed below the given owner node. The arrow will slightly overlap with the owner node.- Parameters:
owner- The owner of the popover.
-
show
public final void show(javafx.scene.Node owner, double offset) Shows the popover in a position relative to the edges of the given owner node. The position is dependent on the arrow location. If the arrow is pointing to the right then the popover will be placed to the left of the given owner. If the arrow points up then the popover will be placed below the given owner node.- Parameters:
owner- The owner of the popover.offset- If negative specifies the distance to the owner node or when positive specifies the number of pixels that the arrow will overlap with the owner node (positive values are recommended).
-
show
public final void show(javafx.stage.Window owner) - Overrides:
showin classjavafx.stage.PopupWindow
-
show
public final void show(javafx.stage.Window ownerWindow, double anchorX, double anchorY) - Overrides:
showin classjavafx.stage.PopupWindow
-
show
public final void show(javafx.scene.Node owner, double x, double y) Makes the popover visible at the give location and associates it with the given owner node. The x and y coordinate will be the target location of the arrow of the popover and not the location of the window.- Overrides:
showin classjavafx.stage.PopupWindow- Parameters:
owner- The owning node.x- The x coordinate for the popover arrow tip.y- The y coordinate for the popover arrow tip.
-
show
public final void show(javafx.scene.Node owner, double x, double y, javafx.util.Duration fadeInDuration) Makes the popover visible at the give location and associates it with the given owner node. The x and y coordinate will be the target location of the arrow of the popover and not the location of the window.- Parameters:
owner- The owning node.x- The x coordinate for the popover arrow tip.y- The y coordinate for the popover arrow tip.fadeInDuration- The time it takes for the popover to be fully visible. This duration takes precedence over the fade-in property without setting.
-
hide
public final void hide()Hides the popover by quickly changing its opacity to 0.- Overrides:
hidein classjavafx.stage.PopupWindow- See Also:
-
hide
public final void hide(javafx.util.Duration fadeOutDuration) Hides the popover by quickly changing its opacity to 0.- Parameters:
fadeOutDuration- The duration of the fade transition that is being used to change the opacity of the popover.
-
detach
public final void detach()Detaches the popover from the owning node. The popover will no longer display an arrow pointing at the owner node. -
contentNodeProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> contentNodeProperty()Specifies the content shown by the popover.- Returns:
- the
contentNodeproperty - See Also:
-
getContentNode
public final javafx.scene.Node getContentNode()Returns the value of the content property.- Returns:
- the content node.
- See Also:
-
setContentNode
public final void setContentNode(javafx.scene.Node content) Sets the value of the content property.- Parameters:
content- The new content node value.- See Also:
-
headerAlwaysVisibleProperty
public final javafx.beans.property.BooleanProperty headerAlwaysVisibleProperty()Determines whether thePopoverheader should remain visible or not, even while attached.- Returns:
- the
headerAlwaysVisibleproperty - See Also:
-
setHeaderAlwaysVisible
public final void setHeaderAlwaysVisible(boolean visible) Sets the value of the headerAlwaysVisible property.- Parameters:
visible- If "true", then the header is visible even while attached.- See Also:
-
isHeaderAlwaysVisible
public final boolean isHeaderAlwaysVisible()Returns the value of the detachable property.- Returns:
- "true" if the header is visible even while attached
- See Also:
-
closeButtonEnabledProperty
public final javafx.beans.property.BooleanProperty closeButtonEnabledProperty()Determines whether the header's close button should be available or not.- Returns:
- the
closeButtonEnabledproperty - See Also:
-
setCloseButtonEnabled
public final void setCloseButtonEnabled(boolean enabled) Sets the value of the closeButtonEnabled property.- Parameters:
enabled- If "false", the popover will not be closeable by the header's close button.- See Also:
-
isCloseButtonEnabled
public final boolean isCloseButtonEnabled()Returns the value of the closeButtonEnabled property.- Returns:
- "true" if the header's close button is enabled
- See Also:
-
detachableProperty
public final javafx.beans.property.BooleanProperty detachableProperty()Determines if the popover is detachable at all.- Returns:
- the
detachableproperty - See Also:
-
setDetachable
public final void setDetachable(boolean detachable) Sets the value of the detachable property.- Parameters:
detachable- If "true" then the user can detach / tear off the popover.- See Also:
-
isDetachable
public final boolean isDetachable()Returns the value of the detachable property.- Returns:
- "true" if the user is allowed to detach / tear off the popover
- See Also:
-
detachedProperty
public final javafx.beans.property.BooleanProperty detachedProperty()Determines whether the popover is detached from the owning node or not. A detached popover no longer shows an arrow pointing at the owner and features its own title bar.- Returns:
- the
detachedproperty - See Also:
-
setDetached
public final void setDetached(boolean detached) Sets the value of the detached property.- Parameters:
detached- If "true" the popover will change its appearance to "detached" mode.- See Also:
-
isDetached
public final boolean isDetached()Returns the value of the detached property.- Returns:
- "true" if the popover is currently detached
- See Also:
-
arrowSizeProperty
public final javafx.beans.property.DoubleProperty arrowSizeProperty()Controls the size of the arrow. Default value is "12".- Returns:
- the
arrowSizeproperty - See Also:
-
getArrowSize
public final double getArrowSize()Returns the value of the arrow size property.- Returns:
- the arrow size property value
- See Also:
-
setArrowSize
public final void setArrowSize(double size) Sets the value of the arrow size property.- Parameters:
size- The new value of the arrow size property.- See Also:
-
arrowIndentProperty
public final javafx.beans.property.DoubleProperty arrowIndentProperty()Controls the distance between the arrow and the corners of the popover. Default value is "12".- Returns:
- the
arrowIndentproperty - See Also:
-
getArrowIndent
public final double getArrowIndent()Returns the value of the arrow indent property.- Returns:
- the arrow indent value
- See Also:
-
setArrowIndent
public final void setArrowIndent(double size) Sets the value of the arrow indent property.- Parameters:
size- The arrow indent value.- See Also:
-
cornerRadiusProperty
public final javafx.beans.property.DoubleProperty cornerRadiusProperty()Returns the corner radius property for the popover. Default value is "6".- Returns:
- the
cornerRadiusproperty - See Also:
-
getCornerRadius
public final double getCornerRadius()Returns the value of the corner radius property.- Returns:
- the corner radius
- See Also:
-
setCornerRadius
public final void setCornerRadius(double radius) Sets the value of the corner radius property.- Parameters:
radius- The corner radius.- See Also:
-
titleProperty
public final javafx.beans.property.StringProperty titleProperty()Stores the title to display in the Popover's header.- Returns:
- the
titleproperty - See Also:
-
getTitle
Returns the value of the title property.- Returns:
- the detached title
- See Also:
-
setTitle
Sets the value of the title property.- Parameters:
title- The title to use when detached.- See Also:
-
arrowLocationProperty
Stores the preferred arrow location. This might not be the actual location of the arrow if auto fix is enabled.- Returns:
- the
arrowLocationproperty - See Also:
-
setArrowLocation
Sets the value of the arrow location property.- Parameters:
location- The requested location.- See Also:
-
getArrowLocation
Returns the value of the arrow location property.- Returns:
- the preferred arrow location
- See Also:
-
fadeInDurationProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Duration> fadeInDurationProperty()Stores the fade-in duration. This should be set before callingPopover.show(..).- Returns:
- the
fadeInDurationproperty - See Also:
-
getFadeInDuration
public final javafx.util.Duration getFadeInDuration()Returns the value of the fade-in duration property.- Returns:
- the fade-in duration
- See Also:
-
setFadeInDuration
public final void setFadeInDuration(javafx.util.Duration duration) Sets the value of the fade-in duration property. This should be set before calling Popover.show(..).- Parameters:
duration- The requested fade-in duration.- See Also:
-
fadeOutDurationProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Duration> fadeOutDurationProperty()Stores the fade-out duration.- Returns:
- the
fadeOutDurationproperty - See Also:
-
getFadeOutDuration
public final javafx.util.Duration getFadeOutDuration()Returns the value of the fade-out duration property.- Returns:
- the fade-out duration
- See Also:
-
setFadeOutDuration
public final void setFadeOutDuration(javafx.util.Duration duration) Sets the value of the fade-out duration property.- Parameters:
duration- The requested fade-out duration.- See Also:
-
animatedProperty
public final javafx.beans.property.BooleanProperty animatedProperty()Stores the "animated" flag. If true then the Popover will be shown / hidden with a short fade in / out animation.- Returns:
- the
animatedproperty - See Also:
-
isAnimated
public final boolean isAnimated()Returns the value of the "animated" property.- Returns:
- "true" if the Popover will be shown and hidden with a short fade animation
- See Also:
-
setAnimated
public final void setAnimated(boolean animated) Sets the value of the "animated" property.- Parameters:
animated- If "true" the Popover will be shown and hidden with a short fade animation.- See Also:
-