- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- javafx.scene.control.Control
-
- org.controlsfx.control.NotificationPane
-
- All Implemented Interfaces:
javafx.css.Styleable,javafx.event.EventTarget,javafx.scene.control.Skinnable
public class NotificationPane extends javafx.scene.control.ControlThe NotificationPane control is a container control that, when prompted by theshow()method, will show a non-modal message to the user. The notification appears as a bar that will slide in to their application window, either from the top or the bottom of the NotificationPane (based onshowFromTopProperty()) wherever that may be in the scenegraph.Alternative Styling
As is visible in the screenshots further down this documentation, there are two different styles supported by the NotificationPane control. Firstly, there is the default style based on the JavaFX Modena look. The alternative style is what is currently referred to as the 'dark' look. To enable this functionality, simply do the following:
NotificationPane notificationPane = new NotificationPane(); notificationPane.getStyleClass().add(NotificationPane.STYLE_CLASS_DARK);Screenshots
To better explain NotificationPane, here is a table showing both the default and dark look for the NotificationPane on a Windows machine (although that shouldn't impact the visuals a great deal). Also, to show the difference between top and bottom placement, these two modes are also captured in the screenshots below:
Setting
Screenshot
Light theme from top: 
Light theme from bottom: 
Dark theme from top: 
Dark theme from bottom: 
Code Examples
NotificationPane is a conceptually very simple control - you simply create your user interface as you normally would, and then wrap it inside the NotificationPane. You can then show a notification bar on top of your content simply by calling
show()on the notification bar. Here is an example:// Create a WebView WebView webView = new WebView(); // Wrap it inside a NotificationPane NotificationPane notificationPane = new NotificationPane(webView); // and put the NotificationPane inside a Tab Tab tab1 = new Tab("Tab 1"); tab1.setContent(notificationPane); // and the Tab inside a TabPane. We just have one tab here, but of course // you can have more! TabPane tabPane = new TabPane(); tabPane.getTabs().addAll(tab1);Now that the notification pane is installed inside the tab, at some point later in you application lifecycle, you can do something like the following to have the notification bar slide into view:
notificationPane.setText("Do you want to save your password?"); notificationPane.getActions().add(new AbstractAction("Save Password") { public void execute(ActionEvent ae) { // do save... // then hide... notificationPane.hide(); } }- See Also:
Action
-
-
Field Summary
Fields Modifier and Type Field Description static javafx.event.EventType<javafx.event.Event>ON_HIDDENCalled when the NotificationPane is hidden.static javafx.event.EventType<javafx.event.Event>ON_HIDINGCalled when the NotificationPane will be hidden.static javafx.event.EventType<javafx.event.Event>ON_SHOWINGCalled when the NotificationPane will be shown.static javafx.event.EventType<javafx.event.Event>ON_SHOWNCalled when the NotificationPane shows.static StringSTYLE_CLASS_DARKStatic fields
-
Constructor Summary
Constructors Constructor Description NotificationPane()NotificationPane(javafx.scene.Node content)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.beans.property.BooleanPropertycloseButtonVisibleProperty()A property representing whether the close button in theNotificationPaneshould be visible or not.javafx.beans.property.ObjectProperty<javafx.scene.Node>contentProperty()The content property represents what is shown in the scene that is not within the notification bar.protected javafx.scene.control.Skin<?>createDefaultSkin()javafx.collections.ObservableList<Action>getActions()Observable list of actions used for the actions area of the notification bar.javafx.scene.NodegetContent()javafx.scene.NodegetGraphic()javafx.event.EventHandler<javafx.event.Event>getOnHidden()javafx.event.EventHandler<javafx.event.Event>getOnHiding()javafx.event.EventHandler<javafx.event.Event>getOnShowing()javafx.event.EventHandler<javafx.event.Event>getOnShown()StringgetText()StringgetUserAgentStylesheet()protected StringgetUserAgentStylesheet(Class<?> clazz, String fileName)A helper method that ensures that the resource based lookup of the user agent stylesheet only happens once.javafx.beans.property.ObjectProperty<javafx.scene.Node>graphicProperty()The graphic property represents theNodeto show within the popup notification bar that appears on top of thecontentthat is within the NotificationPane.voidhide()Call this to make the notification bar disappear from thecontentof thisNotificationPane.booleanisCloseButtonVisible()booleanisShowFromTop()booleanisShowing()javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>>onHiddenProperty()javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>>onHidingProperty()javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>>onShowingProperty()javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>>onShownProperty()voidsetCloseButtonVisible(boolean value)Sets whether the close button inNotificationPaneshould be visible.voidsetContent(javafx.scene.Node value)Set the content to be shown in the scene, that is not within the notification bar.voidsetGraphic(javafx.scene.Node value)Sets theNodeto show within the popup notification bar.voidsetOnHidden(javafx.event.EventHandler<javafx.event.Event> value)Called just after theNotificationPanehas been hidden.voidsetOnHiding(javafx.event.EventHandler<javafx.event.Event> value)Called just prior to theNotificationPanebeing hidden.voidsetOnShowing(javafx.event.EventHandler<javafx.event.Event> value)Called just prior to theNotificationPanebeing shown.voidsetOnShown(javafx.event.EventHandler<javafx.event.Event> value)Called just after theNotificationPaneis shown.voidsetShowFromTop(boolean value)Sets whether the notification bar should appear from the top or the bottom of the NotificationPane area.voidsetText(String value)Sets the text to show within the popup notification bar that appears on top of thecontent.voidshow()Call this to make the notification bar appear on top of thecontentof thisNotificationPane.voidshow(String text)voidshow(String text, javafx.scene.Node graphic)voidshow(String text, javafx.scene.Node graphic, Action... actions)javafx.beans.property.BooleanPropertyshowFromTopProperty()A property representing whether the notification bar should appear from the top or the bottom of the NotificationPane area.javafx.beans.property.ReadOnlyBooleanPropertyshowingProperty()A read-only property that represents whether the notification bar popup should be showing to the user or not.javafx.beans.property.StringPropertytextProperty()The text property represents the text to show within the popup notification bar that appears on top of thecontentthat is within the NotificationPane.-
Methods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty
-
Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
-
Methods inherited from class javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
-
-
-
-
Field Detail
-
STYLE_CLASS_DARK
public static final String STYLE_CLASS_DARK
Static fields- See Also:
- Constant Field Values
-
ON_SHOWING
public static final javafx.event.EventType<javafx.event.Event> ON_SHOWING
Called when the NotificationPane will be shown.
-
ON_SHOWN
public static final javafx.event.EventType<javafx.event.Event> ON_SHOWN
Called when the NotificationPane shows.
-
ON_HIDING
public static final javafx.event.EventType<javafx.event.Event> ON_HIDING
Called when the NotificationPane will be hidden.
-
ON_HIDDEN
public static final javafx.event.EventType<javafx.event.Event> ON_HIDDEN
Called when the NotificationPane is hidden.
-
-
Constructor Detail
-
NotificationPane
public NotificationPane()
-
NotificationPane
public NotificationPane(javafx.scene.Node content)
Creates an instance of NotificationPane with thecontentproperty set, but notextorgraphicproperty set, and noactionsspecified.- Parameters:
content- The content to show in the NotificationPane behind where the notification bar will appear, that is, the content will notappear in the notification bar.
-
-
Method Detail
-
createDefaultSkin
protected javafx.scene.control.Skin<?> createDefaultSkin()
- Overrides:
createDefaultSkinin classjavafx.scene.control.Control
-
getUserAgentStylesheet
public String getUserAgentStylesheet()
- Overrides:
getUserAgentStylesheetin classjavafx.scene.layout.Region
-
contentProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> contentProperty()
The content property represents what is shown in the scene that is not within the notification bar. In other words, it is what the notification bar should appear on top of. For example, in the scenario where you are using a WebView to show to the user websites, and you want to popup up a notification bar to save a password, the content would be the WebView. Refer to theNotificationPaneclass documentation for more details.- Returns:
- A property representing the content of this NotificationPane.
-
setContent
public final void setContent(javafx.scene.Node value)
Set the content to be shown in the scene, that is not within the notification bar.- Parameters:
value-
-
getContent
public final javafx.scene.Node getContent()
- Returns:
- The content shown in the scene.
-
textProperty
public final javafx.beans.property.StringProperty textProperty()
The text property represents the text to show within the popup notification bar that appears on top of thecontentthat is within the NotificationPane.- Returns:
- A property representing the text shown in the notification bar.
-
setText
public final void setText(String value)
Sets the text to show within the popup notification bar that appears on top of thecontent.- Parameters:
value-
-
getText
public final String getText()
- Returns:
- the text showing within the popup
notification bar that appears on top of the
content.
-
graphicProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicProperty()
The graphic property represents theNodeto show within the popup notification bar that appears on top of thecontentthat is within the NotificationPane. Despite the term 'graphic', this can be an arbitrarily complex scenegraph in its own right.- Returns:
- A property representing the graphic shown in the notification bar.
-
setGraphic
public final void setGraphic(javafx.scene.Node value)
Sets theNodeto show within the popup notification bar.- Parameters:
value-
-
getGraphic
public final javafx.scene.Node getGraphic()
- Returns:
- the
Nodeto show within the popup notification bar.
-
showingProperty
public final javafx.beans.property.ReadOnlyBooleanProperty showingProperty()
A read-only property that represents whether the notification bar popup should be showing to the user or not. To toggle visibility, use theshow()andhide()methods.- Returns:
- A property representing whether the notification bar is currently showing.
-
isShowing
public final boolean isShowing()
- Returns:
- whether the notification bar is currently showing.
-
showFromTopProperty
public final javafx.beans.property.BooleanProperty showFromTopProperty()
A property representing whether the notification bar should appear from the top or the bottom of the NotificationPane area. By default it will appear from the top, but this can be changed by setting this property to false.- Returns:
- A property representing where the notification bar should appear from.
-
setShowFromTop
public final void setShowFromTop(boolean value)
Sets whether the notification bar should appear from the top or the bottom of the NotificationPane area.- Parameters:
value-
-
isShowFromTop
public final boolean isShowFromTop()
- Returns:
- whether the notification bar is appearing from the top or the bottom of the NotificationPane area.
-
onShowingProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>> onShowingProperty()
-
setOnShowing
public final void setOnShowing(javafx.event.EventHandler<javafx.event.Event> value)
Called just prior to theNotificationPanebeing shown.
-
getOnShowing
public final javafx.event.EventHandler<javafx.event.Event> getOnShowing()
-
onShownProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>> onShownProperty()
-
setOnShown
public final void setOnShown(javafx.event.EventHandler<javafx.event.Event> value)
Called just after theNotificationPaneis shown.
-
getOnShown
public final javafx.event.EventHandler<javafx.event.Event> getOnShown()
-
onHidingProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>> onHidingProperty()
-
setOnHiding
public final void setOnHiding(javafx.event.EventHandler<javafx.event.Event> value)
Called just prior to theNotificationPanebeing hidden.
-
getOnHiding
public final javafx.event.EventHandler<javafx.event.Event> getOnHiding()
-
onHiddenProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<javafx.event.Event>> onHiddenProperty()
-
setOnHidden
public final void setOnHidden(javafx.event.EventHandler<javafx.event.Event> value)
Called just after theNotificationPanehas been hidden.
-
getOnHidden
public final javafx.event.EventHandler<javafx.event.Event> getOnHidden()
-
closeButtonVisibleProperty
public final javafx.beans.property.BooleanProperty closeButtonVisibleProperty()
A property representing whether the close button in theNotificationPaneshould be visible or not. By default it will appear but this can be changed by setting this property to false.- Returns:
- A property representing whether the close button in the
NotificationPaneshould be visible.
-
setCloseButtonVisible
public final void setCloseButtonVisible(boolean value)
Sets whether the close button inNotificationPaneshould be visible.- Parameters:
value-
-
isCloseButtonVisible
public final boolean isCloseButtonVisible()
- Returns:
- whether the close button in
NotificationPaneis visible.
-
getActions
public final javafx.collections.ObservableList<Action> getActions()
Observable list of actions used for the actions area of the notification bar. Modifying the contents of this list will change the actions available to the user.- Returns:
- The
ObservableListof actions available to the user.
-
show
public void show()
Call this to make the notification bar appear on top of thecontentof thisNotificationPane. If the notification bar is already showing this will be a no-op.
-
show
public void show(String text)
Shows the NotificationPane with thecontentandtextproperty set, but nographicproperty set, and noactionsspecified.- Parameters:
text- The text to show in the notification pane.
-
show
public void show(String text, javafx.scene.Node graphic)
Shows the NotificationPane with thecontent,textandgraphicproperties set, but noactionsspecified.- Parameters:
text- The text to show in the notification pane.graphic- The node to show in the notification pane.
-
show
public void show(String text, javafx.scene.Node graphic, Action... actions)
Shows the NotificationPane with thecontent,textandgraphicproperty set, and the provided actions copied into theactionslist.- Parameters:
text- The text to show in the notification pane.graphic- The node to show in the notification pane.actions- The actions to show in the notification pane.
-
hide
public void hide()
Call this to make the notification bar disappear from thecontentof thisNotificationPane. If the notification bar is already hidden this will be a no-op.
-
getUserAgentStylesheet
protected final String getUserAgentStylesheet(Class<?> clazz, String fileName)
A helper method that ensures that the resource based lookup of the user agent stylesheet only happens once. Caches the external form of the resource.- Parameters:
clazz- the class used for the resource lookupfileName- the name of the user agent stylesheet- Returns:
- the external form of the user agent stylesheet (the path)
-
-