public class NotificationPane extends Control
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.
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);
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: | ![]() |
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();
}
}Action,
AbstractAction| Type | Property and Description |
|---|---|
ObjectProperty<Node> |
content
The content property represents what is shown in the scene
that is not within the notification bar.
|
ObjectProperty<Node> |
graphic
|
ObjectProperty<EventHandler<Event>> |
onHidden |
ObjectProperty<EventHandler<Event>> |
onHiding |
ObjectProperty<EventHandler<Event>> |
onShowing |
ObjectProperty<EventHandler<Event>> |
onShown |
BooleanProperty |
showFromTop
A property representing whether the notification bar should appear from the
top or the bottom of the NotificationPane area.
|
ReadOnlyBooleanProperty |
showing
A read-only property that represents whether the notification bar popup
should be showing to the user or not.
|
StringProperty |
text
The text property represents the text to show within the popup
notification bar that appears on top of the
content that is within the NotificationPane. |
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipPropertybackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthPropertyimpl_traversalEngineProperty, needsLayoutPropertyblendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, impl_showMnemonicsProperty, impl_treeVisibleProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, 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, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty| Modifier and Type | Field and Description |
|---|---|
static EventType<Event> |
ON_HIDDEN
Called when the NotificationPane is hidden.
|
static EventType<Event> |
ON_HIDING
Called when the NotificationPane will be hidden.
|
static EventType<Event> |
ON_SHOWING
Called when the NotificationPane will be shown.
|
static EventType<Event> |
ON_SHOWN
Called when the NotificationPane shows.
|
static String |
STYLE_CLASS_DARK
Static fields
|
USE_COMPUTED_SIZE, USE_PREF_SIZEBASELINE_OFFSET_SAME_AS_HEIGHT| Constructor and Description |
|---|
NotificationPane()
|
NotificationPane(Node content)
|
| Modifier and Type | Method and Description |
|---|---|
ObjectProperty<Node> |
contentProperty()
The content property represents what is shown in the scene
that is not within the notification bar.
|
protected Skin<?> |
createDefaultSkin() |
ObservableList<Action> |
getActions()
Observable list of actions used for the actions area of the notification
bar.
|
Node |
getContent()
Gets the value of the property content.
|
Node |
getGraphic()
Gets the value of the property graphic.
|
EventHandler<Event> |
getOnHidden()
Gets the value of the property onHidden.
|
EventHandler<Event> |
getOnHiding()
Gets the value of the property onHiding.
|
EventHandler<Event> |
getOnShowing()
Gets the value of the property onShowing.
|
EventHandler<Event> |
getOnShown()
Gets the value of the property onShown.
|
String |
getText()
Gets the value of the property text.
|
protected String |
getUserAgentStylesheet() |
ObjectProperty<Node> |
graphicProperty()
|
void |
hide()
Call this to make the notification bar disappear from the
content of this NotificationPane. |
boolean |
isShowFromTop()
Gets the value of the property showFromTop.
|
boolean |
isShowing()
Gets the value of the property showing.
|
ObjectProperty<EventHandler<Event>> |
onHiddenProperty() |
ObjectProperty<EventHandler<Event>> |
onHidingProperty() |
ObjectProperty<EventHandler<Event>> |
onShowingProperty() |
ObjectProperty<EventHandler<Event>> |
onShownProperty() |
void |
setContent(Node value)
Sets the value of the property content.
|
void |
setGraphic(Node value)
Sets the value of the property graphic.
|
void |
setOnHidden(EventHandler<Event> value)
Called just after the
NotificationPane has been hidden. |
void |
setOnHiding(EventHandler<Event> value)
Called just prior to the
NotificationPane being hidden. |
void |
setOnShowing(EventHandler<Event> value)
Called just prior to the
NotificationPane being shown. |
void |
setOnShown(EventHandler<Event> value)
Called just after the
NotificationPane is shown. |
void |
setShowFromTop(boolean value)
Sets the value of the property showFromTop.
|
void |
setText(String value)
Sets the value of the property text.
|
void |
show()
Call this to make the notification bar appear on top of the
content of this NotificationPane. |
void |
show(String text)
|
void |
show(String text,
Node graphic)
|
void |
show(String text,
Node graphic,
Action... actions)
|
BooleanProperty |
showFromTopProperty()
A property representing whether the notification bar should appear from the
top or the bottom of the NotificationPane area.
|
ReadOnlyBooleanProperty |
showingProperty()
A read-only property that represents whether the notification bar popup
should be showing to the user or not.
|
StringProperty |
textProperty()
The text property represents the text to show within the popup
notification bar that appears on top of the
content that is within the NotificationPane. |
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getSkin, getTooltip, impl_cssGetFocusTraversableInitialValue, impl_processCSS, isResizable, layoutChildren, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipPropertybackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, 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, snapSize, snapSpace, snapToPixelProperty, widthPropertygetChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBoundsaddEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, 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, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_geomChanged, impl_getAccessible, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, 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, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, 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, screenToLocal, screenToLocal, screenToLocal, 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, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visiblePropertypublic final ObjectProperty<Node> contentProperty
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 the
NotificationPane class documentation for more details.public final StringProperty textProperty
content that is within the NotificationPane.getText(),
setText(String)public final ObjectProperty<Node> graphicProperty
Node to show within the popup
notification bar that appears on top of the
content that is within the NotificationPane.
Despite the term 'graphic', this can be an arbitrarily complex scenegraph
in its own right.getGraphic(),
setGraphic(Node)public final ReadOnlyBooleanProperty showingProperty
show() and hide() methods.isShowing()public final BooleanProperty showFromTopProperty
isShowFromTop(),
setShowFromTop(boolean)public final ObjectProperty<EventHandler<Event>> onShowingProperty
getOnShowing(),
setOnShowing(EventHandler)public final ObjectProperty<EventHandler<Event>> onShownProperty
getOnShown(),
setOnShown(EventHandler)public final ObjectProperty<EventHandler<Event>> onHidingProperty
getOnHiding(),
setOnHiding(EventHandler)public final ObjectProperty<EventHandler<Event>> onHiddenProperty
getOnHidden(),
setOnHidden(EventHandler)public static final String STYLE_CLASS_DARK
public static final EventType<Event> ON_SHOWING
public static final EventType<Event> ON_HIDING
public NotificationPane()
public NotificationPane(Node content)
content property set, but no
text or
graphic property set, and no
actions specified.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.protected Skin<?> createDefaultSkin()
createDefaultSkin in class Controlprotected String getUserAgentStylesheet()
getUserAgentStylesheet in class Controlpublic final ObjectProperty<Node> contentProperty()
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 the
NotificationPane class documentation for more details.public final void setContent(Node value)
public final Node getContent()
public final StringProperty textProperty()
content that is within the NotificationPane.getText(),
setText(String)public final void setText(String value)
public final String getText()
public final ObjectProperty<Node> graphicProperty()
Node to show within the popup
notification bar that appears on top of the
content that is within the NotificationPane.
Despite the term 'graphic', this can be an arbitrarily complex scenegraph
in its own right.getGraphic(),
setGraphic(Node)public final void setGraphic(Node value)
public final Node getGraphic()
public final ReadOnlyBooleanProperty showingProperty()
show() and hide() methods.isShowing()public final boolean isShowing()
public final BooleanProperty showFromTopProperty()
isShowFromTop(),
setShowFromTop(boolean)public final void setShowFromTop(boolean value)
public final boolean isShowFromTop()
public final ObjectProperty<EventHandler<Event>> onShowingProperty()
getOnShowing(),
setOnShowing(EventHandler)public final void setOnShowing(EventHandler<Event> value)
NotificationPane being shown.public final EventHandler<Event> getOnShowing()
public final ObjectProperty<EventHandler<Event>> onShownProperty()
getOnShown(),
setOnShown(EventHandler)public final void setOnShown(EventHandler<Event> value)
NotificationPane is shown.public final EventHandler<Event> getOnShown()
public final ObjectProperty<EventHandler<Event>> onHidingProperty()
getOnHiding(),
setOnHiding(EventHandler)public final void setOnHiding(EventHandler<Event> value)
NotificationPane being hidden.public final EventHandler<Event> getOnHiding()
public final ObjectProperty<EventHandler<Event>> onHiddenProperty()
getOnHidden(),
setOnHidden(EventHandler)public final void setOnHidden(EventHandler<Event> value)
NotificationPane has been hidden.public final EventHandler<Event> getOnHidden()
public final ObservableList<Action> getActions()
ObservableList of actions available to the user.public void show()
content of this NotificationPane.
If the notification bar is already showing this will be a no-op.public void show(String text)
content and text
property set, but no graphic property set, and
no actions specified.text - The text to show in the notification pane.public void show(String text, Node graphic)
content, text and
graphic properties set, but no
actions specified.text - The text to show in the notification pane.graphic - The node to show in the notification pane.public void show(String text, Node graphic, Action... actions)
content, text and
graphic property set, and the provided actions
copied into the actions list.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.public void hide()
content of this NotificationPane.
If the notification bar is already hidden this will be a no-op.