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
| Modifier and Type | Field and Description |
|---|---|
| private final ObservableList | actions
Public API |
| private BooleanProperty | |
| private ObjectProperty | content
Properties |
| private static final String | DEFAULT_STYLE_CLASS
* Stylesheet Handling * * |
| private ObjectProperty | |
| public static final EventType | ON_HIDDEN
Called when the NotificationPane is hidden. |
| public static final EventType | ON_HIDING
Called when the NotificationPane will be hidden. |
| public static final EventType | ON_SHOWING
Called when the NotificationPane will be shown. |
| public static final EventType | ON_SHOWN
Called when the NotificationPane shows. |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private BooleanProperty | |
| private ReadOnlyBooleanWrapper | |
| public static final String | STYLE_CLASS_DARK
Static fields |
| private StringProperty |
| Access | Constructor and Description |
|---|---|
| public | NotificationPane()
Creates an instance of NotificationPane with no
|
| public | NotificationPane(Node
The content to show in the NotificationPane behind where
the notification bar will appear, that is, the content
will notappear in the notification bar. content)Creates an instance of NotificationPane with the
|
| Modifier and Type | Method and Description |
|---|---|
| public final BooleanProperty | Returns: A property representing whether the close button in theNotificationPane should be visible.A property representing whether the close button in the |
| public final ObjectProperty | Returns: A property representing the content of this NotificationPane.The content property represents what is shown in the scene that is not within the notification bar. |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public final ObservableList | Returns: TheObservableList of actions available to the user.Observable list of actions used for the actions area of the notification bar. |
| public final Node | |
| public final Node | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final String | |
| public String | getUserAgentStylesheet()
Overrides javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| public final ObjectProperty | Returns: A property representing the graphic shown in the notification bar.The graphic property represents the |
| public void | |
| private void | |
| public final boolean | |
| public final boolean | isShowFromTop()
Returns: whether the notification bar is appearing from the top or the bottom of the NotificationPane area. |
| public final boolean | |
| private static EventType | Returns: the new EventType instancethe name of the new EventType to create name)Static factory method for NotificationPane EventTypes. |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final void | setCloseButtonVisible(boolean value)
Sets whether the close button in |
| public final void | setContent(Node value)
Set the content to be shown in the scene, that is not within the notification bar. |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | setShowFromTop(boolean value)
Sets whether the notification bar should appear from the top or the bottom of the NotificationPane area. |
| private final void | |
| public final void | |
| public void | |
| public void | |
| public void | |
| public void | show(final String
The text to show in the notification pane. text, final Node The node to show in the notification pane. graphic, final Action... The actions to show in the notification pane. actions)Shows the NotificationPane with the
|
| public final BooleanProperty | Returns: A property representing where the notification bar should appear from.A property representing whether the notification bar should appear from the top or the bottom of the NotificationPane area. |
| public final ReadOnlyBooleanProperty | Returns: A property representing whether the notification bar is currently showing.A read-only property that represents whether the notification bar popup should be showing to the user or not. |
| public final StringProperty | Returns: A property representing the text shown in the notification bar.The text property represents the text to show within the popup
notification bar that appears on top of the
|
| private void |
| actions | back to summary |
|---|---|
| private final ObservableList<Action> actions Public API | |
| closeButtonVisible | back to summary |
|---|---|
| private BooleanProperty closeButtonVisible | |
| content | back to summary |
|---|---|
| private ObjectProperty<Node> content Properties | |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS * Stylesheet Handling * * | |
| graphic | back to summary |
|---|---|
| private ObjectProperty<Node> graphic | |
| ON_HIDDEN | back to summary |
|---|---|
| public static final EventType<Event> ON_HIDDEN Called when the NotificationPane is hidden. | |
| ON_HIDING | back to summary |
|---|---|
| public static final EventType<Event> ON_HIDING Called when the NotificationPane will be hidden. | |
| ON_SHOWING | back to summary |
|---|---|
| public static final EventType<Event> ON_SHOWING Called when the NotificationPane will be shown. | |
| ON_SHOWN | back to summary |
|---|---|
| public static final EventType<Event> ON_SHOWN Called when the NotificationPane shows. | |
| onHidden | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onHidden | |
| onHiding | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onHiding | |
| onShowing | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onShowing | |
| onShown | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onShown | |
| showFromTop | back to summary |
|---|---|
| private BooleanProperty showFromTop | |
| showing | back to summary |
|---|---|
| private ReadOnlyBooleanWrapper showing | |
| STYLE_CLASS_DARK | back to summary |
|---|---|
| public static final String STYLE_CLASS_DARK Static fields | |
| text | back to summary |
|---|---|
| private StringProperty text | |
| NotificationPane | back to summary |
|---|---|
| public NotificationPane() Creates an instance of NotificationPane with no
| |
| NotificationPane | back to summary |
|---|---|
| public NotificationPane(Node content) Creates an instance of NotificationPane with the
| |
| closeButtonVisibleProperty | back to summary |
|---|---|
| public final BooleanProperty closeButtonVisibleProperty() A property representing whether the close button in the
| |
| contentProperty | back to summary |
|---|---|
| public final ObjectProperty 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 the
| |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS
| |
| getActions | back to summary |
|---|---|
| public final ObservableList 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.
| |
| getContent | back to summary |
|---|---|
public final Node getContent()
| |
| getGraphic | back to summary |
|---|---|
| public final Node getGraphic() | |
| getOnHidden | back to summary |
|---|---|
| public final EventHandler | |
| getOnHiding | back to summary |
|---|---|
| public final EventHandler | |
| getOnShowing | back to summary |
|---|---|
| public final EventHandler | |
| getOnShown | back to summary |
|---|---|
| public final EventHandler | |
| getText | back to summary |
|---|---|
| public final String getText() | |
| getUserAgentStylesheet | back to summary |
|---|---|
| public String getUserAgentStylesheet() Overrides javafx. Doc from javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls. The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath. Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.
| |
| graphicProperty | back to summary |
|---|---|
| public final ObjectProperty The graphic property represents the
| |
| hide | back to summary |
|---|---|
| public void hide() Call this to make the notification bar disappear from the
| |
| hideAndThen | back to summary |
|---|---|
| private void hideAndThen(final Runnable r) | |
| isCloseButtonVisible | back to summary |
|---|---|
public final boolean isCloseButtonVisible()
| |
| isShowFromTop | back to summary |
|---|---|
public final boolean isShowFromTop()
| |
| isShowing | back to summary |
|---|---|
public final boolean isShowing()
| |
| newEventType | back to summary |
|---|---|
| private static EventType Static factory method for NotificationPane EventTypes. | |
| onHiddenProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| onHidingProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| onShowingProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| onShownProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| setCloseButtonVisible | back to summary |
|---|---|
| public final void setCloseButtonVisible(boolean value) Sets whether the close button in | |
| setContent | back to summary |
|---|---|
| public final void setContent(Node value) Set the content to be shown in the scene, that is not within the notification bar. | |
| setGraphic | back to summary |
|---|---|
| public final void setGraphic(Node value) Sets the | |
| setOnHidden | back to summary |
|---|---|
| public final void setOnHidden(EventHandler<Event> value) Called just after the | |
| setOnHiding | back to summary |
|---|---|
| public final void setOnHiding(EventHandler<Event> value) Called just prior to the | |
| setOnShowing | back to summary |
|---|---|
| public final void setOnShowing(EventHandler<Event> value) Called just prior to the | |
| setOnShown | back to summary |
|---|---|
| public final void setOnShown(EventHandler<Event> value) Called just after the | |
| setShowFromTop | back to summary |
|---|---|
| public final void setShowFromTop(boolean value) Sets whether the notification bar should appear from the top or the bottom of the NotificationPane area. | |
| setShowing | back to summary |
|---|---|
| private final void setShowing(boolean value) | |
| setText | back to summary |
|---|---|
| public final void setText(String value) Sets the text to show within the popup
notification bar that appears on top of the
| |
| show | back to summary |
|---|---|
| public void show() Call this to make the notification bar appear on top of the
| |
| show | back to summary |
|---|---|
| public void show(final String text) Shows the NotificationPane with the
| |
| show | back to summary |
|---|---|
| public void show(final String text, final Node graphic) Shows the NotificationPane with the
| |
| show | back to summary |
|---|---|
| public void show(final String text, final Node graphic, final Action... actions) Shows the NotificationPane with the
| |
| showFromTopProperty | back to summary |
|---|---|
| public final 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.
| |
| showingProperty | back to summary |
|---|---|
| public final 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 the
| |
| textProperty | back to summary |
|---|---|
| public final StringProperty textProperty() The text property represents the text to show within the popup
notification bar that appears on top of the
| |
| updateStyleClasses | back to summary |
|---|---|
| private void updateStyleClasses() * Private Implementation * * | |