- All Implemented Interfaces:
Styleable,EventTarget,Skinnable
show() 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 on
showFromTopProperty()) 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:
-
Property Summary
PropertiesTypePropertyDescriptionfinal BooleanPropertyA property representing whether the close button in theNotificationPaneshould be visible or not.final ObjectProperty<Node>The content property represents what is shown in the scene that is not within the notification bar.final ObjectProperty<Node>final ObjectProperty<EventHandler<Event>>final ObjectProperty<EventHandler<Event>>final ObjectProperty<EventHandler<Event>>final ObjectProperty<EventHandler<Event>>final BooleanPropertyA property representing whether the notification bar should appear from the top or the bottom of the NotificationPane area.final ReadOnlyBooleanPropertyA read-only property that represents whether the notification bar popup should be showing to the user or not.final StringPropertyThe text property represents the text to show within the popup notification bar that appears on top of thecontentthat is within the NotificationPane.Properties inherited from class javafx.scene.control.Control
contextMenu, skin, tooltipProperties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class javafx.scene.Parent
needsLayoutProperties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible -
Field Summary
FieldsModifier and TypeFieldDescriptionCalled when the NotificationPane is hidden.Called when the NotificationPane will be hidden.Called when the NotificationPane will be shown.Called when the NotificationPane shows.static final StringStatic fieldsFields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal BooleanPropertyA property representing whether the close button in theNotificationPaneshould be visible or not.final ObjectProperty<Node>The content property represents what is shown in the scene that is not within the notification bar.protected Skin<?>final ObservableList<Action>Observable list of actions used for the actions area of the notification bar.final Nodefinal Nodefinal EventHandler<Event>Gets the value of the property onHidden.final EventHandler<Event>Gets the value of the property onHiding.final EventHandler<Event>Gets the value of the property onShowing.final EventHandler<Event>Gets the value of the property onShown.final StringgetText()protected final StringgetUserAgentStylesheet(Class<?> clazz, String fileName) A helper method that ensures that the resource based lookup of the user agent stylesheet only happens once.final ObjectProperty<Node>voidhide()Call this to make the notification bar disappear from thecontentof thisNotificationPane.final booleanfinal booleanfinal booleanfinal ObjectProperty<EventHandler<Event>>final ObjectProperty<EventHandler<Event>>final ObjectProperty<EventHandler<Event>>final ObjectProperty<EventHandler<Event>>final voidsetCloseButtonVisible(boolean value) Sets whether the close button inNotificationPaneshould be visible.final voidsetContent(Node value) Set the content to be shown in the scene, that is not within the notification bar.final voidsetGraphic(Node value) Sets theNodeto show within the popup notification bar.final voidsetOnHidden(EventHandler<Event> value) Called just after theNotificationPanehas been hidden.final voidsetOnHiding(EventHandler<Event> value) Called just prior to theNotificationPanebeing hidden.final voidsetOnShowing(EventHandler<Event> value) Called just prior to theNotificationPanebeing shown.final voidsetOnShown(EventHandler<Event> value) Called just after theNotificationPaneis shown.final voidsetShowFromTop(boolean value) Sets whether the notification bar should appear from the top or the bottom of the NotificationPane area.final voidSets 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.voidvoidvoidfinal BooleanPropertyA property representing whether the notification bar should appear from the top or the bottom of the NotificationPane area.final ReadOnlyBooleanPropertyA read-only property that represents whether the notification bar popup should be showing to the user or not.final StringPropertyThe 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, tooltipPropertyMethods 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, widthPropertyMethods inherited from class javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBoundsMethods 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, visiblePropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
content
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.
-
text
The text property represents the text to show within the popup notification bar that appears on top of thecontentthat is within the NotificationPane.- See Also:
-
graphic
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.- See Also:
-
showing
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.- See Also:
-
showFromTop
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.- See Also:
-
onShowing
- See Also:
-
onShown
- See Also:
-
onHiding
- See Also:
-
onHidden
- See Also:
-
closeButtonVisible
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.
-
-
Field Details
-
STYLE_CLASS_DARK
Static fields- See Also:
-
ON_SHOWING
Called when the NotificationPane will be shown. -
ON_SHOWN
Called when the NotificationPane shows. -
ON_HIDING
Called when the NotificationPane will be hidden. -
ON_HIDDEN
Called when the NotificationPane is hidden.
-
-
Constructor Details
-
NotificationPane
public NotificationPane() -
NotificationPane
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 Details
-
createDefaultSkin
- Overrides:
createDefaultSkinin classControl
-
getUserAgentStylesheet
- Overrides:
getUserAgentStylesheetin classRegion
-
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
Set the content to be shown in the scene, that is not within the notification bar.- Parameters:
value-
-
getContent
- Returns:
- The content shown in the scene.
-
textProperty
The text property represents the text to show within the popup notification bar that appears on top of thecontentthat is within the NotificationPane.- See Also:
-
setText
Sets the text to show within the popup notification bar that appears on top of thecontent.- Parameters:
value-
-
getText
- Returns:
- the text showing within the popup
notification bar that appears on top of the
content.
-
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.- See Also:
-
setGraphic
Sets theNodeto show within the popup notification bar.- Parameters:
value-
-
getGraphic
- Returns:
- the
Nodeto show within the popup notification bar.
-
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.- See Also:
-
isShowing
public final boolean isShowing()- Returns:
- whether the notification bar is currently showing.
-
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.- See Also:
-
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
- See Also:
-
setOnShowing
Called just prior to theNotificationPanebeing shown. -
getOnShowing
Gets the value of the property onShowing.- Property description:
-
onShownProperty
- See Also:
-
setOnShown
Called just after theNotificationPaneis shown. -
getOnShown
Gets the value of the property onShown.- Property description:
-
onHidingProperty
- See Also:
-
setOnHiding
Called just prior to theNotificationPanebeing hidden. -
getOnHiding
Gets the value of the property onHiding.- Property description:
-
onHiddenProperty
- See Also:
-
setOnHidden
Called just after theNotificationPanehas been hidden. -
getOnHidden
Gets the value of the property onHidden.- Property description:
-
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. -
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
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
Shows the NotificationPane with thecontentandtextproperty set, but nographicproperty set, and noactionsspecified.- Parameters:
text- The text to show in the notification pane.
-
show
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
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
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)
-



