Top Description Fields Constructors Methods
org.controlsfx.control

public Class NotificationPane

extends ControlsFXControl
Class Inheritance
Imports
impl.org.controlsfx.skin.NotificationPaneSkin, java.util.UUID, javafx.beans.property.BooleanProperty, .ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .SimpleBooleanProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.collections.FXCollections, .ObservableList, javafx.event.Event, .EventHandler, .EventType, javafx.scene.Node, javafx.scene.control.Skin, org.controlsfx.control.action.Action

The NotificationPane control is a container control that, when prompted by the 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:
Screenshot of NotificationPane - Light theme from top
Light theme from bottom:
Screenshot of NotificationPane - Light theme from bottom
Dark theme from top:
Screenshot of NotificationPane - Dark theme from top
Dark theme from bottom:
Screenshot of NotificationPane - 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

Modifier and TypeField and Description
private final ObservableList<Action>
actions

Public API

private BooleanProperty
private ObjectProperty<Node>
content

Properties

private static final String
DEFAULT_STYLE_CLASS

* Stylesheet Handling * *

private ObjectProperty<Node>
public static final EventType<Event>
ON_HIDDEN

Called when the NotificationPane is hidden.

public static final EventType<Event>
ON_HIDING

Called when the NotificationPane will be hidden.

public static final EventType<Event>
ON_SHOWING

Called when the NotificationPane will be shown.

public static final EventType<Event>
ON_SHOWN

Called when the NotificationPane shows.

private ObjectProperty<EventHandler<Event>>
private ObjectProperty<EventHandler<Event>>
private ObjectProperty<EventHandler<Event>>
private ObjectProperty<EventHandler<Event>>
private BooleanProperty
private ReadOnlyBooleanWrapper
public static final String
STYLE_CLASS_DARK

Static fields

private StringProperty

Constructor Summary

AccessConstructor and Description
public
NotificationPane()

Creates an instance of NotificationPane with no content, text, graphic properties set, and no actions specified.

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 content property set, but no text or graphic property set, and no actions specified.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty

Returns:

A property representing whether the close button in the NotificationPane should be visible.
closeButtonVisibleProperty
()

A property representing whether the close button in the NotificationPane should be visible or not.

public final ObjectProperty<Node>

Returns:

A property representing the content of this NotificationPane.
contentProperty
()

The content property represents what is shown in the scene that is not within the notification bar.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObservableList<Action>

Returns:

The ObservableList of actions available to the user.
getActions
()

Observable list of actions used for the actions area of the notification bar.

public final Node
getContent()

Returns: The content shown in the scene.

public final Node
getGraphic()

Returns: the Node to show within the popup notification bar.

public final EventHandler<Event>
public final EventHandler<Event>
public final EventHandler<Event>
public final EventHandler<Event>
public final String
getText()

Returns: the text showing within the popup notification bar that appears on top of the content.

public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final ObjectProperty<Node>

Returns:

A property representing the graphic shown in the notification bar.
graphicProperty
()

The graphic property represents the Node to show within the popup notification bar that appears on top of the content that is within the NotificationPane.

public void
hide()

Call this to make the notification bar disappear from the content of this NotificationPane.

private void
public final boolean
isCloseButtonVisible()

Returns: whether the close button in NotificationPane is visible.

public final boolean
isShowFromTop()

Returns: whether the notification bar is appearing from the top or the bottom of the NotificationPane area.

public final boolean
isShowing()

Returns: whether the notification bar is currently showing.

private static EventType<Event>

Returns:

the new EventType instance
newEventType
(String
the name of the new EventType to create
name
)

Static factory method for NotificationPane EventTypes.

public final ObjectProperty<EventHandler<Event>>
public final ObjectProperty<EventHandler<Event>>
public final ObjectProperty<EventHandler<Event>>
public final ObjectProperty<EventHandler<Event>>
public final void
setCloseButtonVisible(boolean value)

Sets whether the close button in NotificationPane should be visible.

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
setGraphic(Node value)

Sets the Node to show within the popup notification bar.

public final void
setOnHidden(EventHandler<Event> value)

Called just after the NotificationPane has been hidden.

public final void
setOnHiding(EventHandler<Event> value)

Called just prior to the NotificationPane being hidden.

public final void
setOnShowing(EventHandler<Event> value)

Called just prior to the NotificationPane being shown.

public final void
setOnShown(EventHandler<Event> value)

Called just after the NotificationPane is shown.

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
setShowing(boolean value)

public final void
setText(String value)

Sets the text to show within the popup notification bar that appears on top of the content.

public void
show()

Call this to make the notification bar appear on top of the content of this NotificationPane.

public void
show(final String
The text to show in the notification pane.
text
)

Shows the NotificationPane with the content and text property set, but no graphic property set, and no actions specified.

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
)

Shows the NotificationPane with the content, text and graphic properties set, but no actions specified.

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 content, text and graphic property set, and the provided actions copied into the actions list.

public final BooleanProperty

Returns:

A property representing where the notification bar should appear from.
showFromTopProperty
()

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.
showingProperty
()

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.
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.

private void
updateStyleClasses()

* Private Implementation * *

Inherited from org.controlsfx.control.ControlsFXControl:
getUserAgentStylesheet

Field Detail

actionsback to summary
private final ObservableList<Action> actions

Public API

closeButtonVisibleback to summary
private BooleanProperty closeButtonVisible
contentback to summary
private ObjectProperty<Node> content

Properties

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

* Stylesheet Handling * *

graphicback to summary
private ObjectProperty<Node> graphic
ON_HIDDENback to summary
public static final EventType<Event> ON_HIDDEN

Called when the NotificationPane is hidden.

ON_HIDINGback to summary
public static final EventType<Event> ON_HIDING

Called when the NotificationPane will be hidden.

ON_SHOWINGback to summary
public static final EventType<Event> ON_SHOWING

Called when the NotificationPane will be shown.

ON_SHOWNback to summary
public static final EventType<Event> ON_SHOWN

Called when the NotificationPane shows.

onHiddenback to summary
private ObjectProperty<EventHandler<Event>> onHidden
onHidingback to summary
private ObjectProperty<EventHandler<Event>> onHiding
onShowingback to summary
private ObjectProperty<EventHandler<Event>> onShowing
onShownback to summary
private ObjectProperty<EventHandler<Event>> onShown
showFromTopback to summary
private BooleanProperty showFromTop
showingback to summary
private ReadOnlyBooleanWrapper showing
STYLE_CLASS_DARKback to summary
public static final String STYLE_CLASS_DARK

Static fields

textback to summary
private StringProperty text

Constructor Detail

NotificationPaneback to summary
public NotificationPane()

Creates an instance of NotificationPane with no content, text, graphic properties set, and no actions specified.

NotificationPaneback to summary
public NotificationPane(Node content)

Creates an instance of NotificationPane with the content property set, but no text or graphic property set, and no actions specified.

Parameters
content: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.

Method Detail

closeButtonVisiblePropertyback to summary
public final BooleanProperty closeButtonVisibleProperty()

A property representing whether the close button in the NotificationPane should be visible or not. By default it will appear but this can be changed by setting this property to false.

Returns:BooleanProperty

A property representing whether the close button in the NotificationPane should be visible.

contentPropertyback to summary
public final ObjectProperty<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 the NotificationPane class documentation for more details.

Returns:ObjectProperty<Node>

A property representing the content of this NotificationPane.

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

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 -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
getActionsback to summary
public final 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:ObservableList<Action>

The ObservableList of actions available to the user.

getContentback to summary
public final Node getContent()
Returns:Node

The content shown in the scene.

getGraphicback to summary
public final Node getGraphic()
Returns:Node

the Node to show within the popup notification bar.

getOnHiddenback to summary
public final EventHandler<Event> getOnHidden()
getOnHidingback to summary
public final EventHandler<Event> getOnHiding()
getOnShowingback to summary
public final EventHandler<Event> getOnShowing()
getOnShownback to summary
public final EventHandler<Event> getOnShown()
getTextback to summary
public final String getText()
Returns:String

the text showing within the popup notification bar that appears on top of the content.

getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

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.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
graphicPropertyback to summary
public final ObjectProperty<Node> graphicProperty()

The graphic property represents the 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.

Returns:ObjectProperty<Node>

A property representing the graphic shown in the notification bar.

hideback to summary
public void hide()

Call this to make the notification bar disappear from the content of this NotificationPane. If the notification bar is already hidden this will be a no-op.

hideAndThenback to summary
private void hideAndThen(final Runnable r)
isCloseButtonVisibleback to summary
public final boolean isCloseButtonVisible()
Returns:boolean

whether the close button in NotificationPane is visible.

isShowFromTopback to summary
public final boolean isShowFromTop()
Returns:boolean

whether the notification bar is appearing from the top or the bottom of the NotificationPane area.

isShowingback to summary
public final boolean isShowing()
Returns:boolean

whether the notification bar is currently showing.

newEventTypeback to summary
private static EventType<Event> newEventType(String name)

Static factory method for NotificationPane EventTypes.

Parameters
name:String

the name of the new EventType to create

Returns:EventType<Event>

the new EventType instance

onHiddenPropertyback to summary
public final ObjectProperty<EventHandler<Event>> onHiddenProperty()
onHidingPropertyback to summary
public final ObjectProperty<EventHandler<Event>> onHidingProperty()
onShowingPropertyback to summary
public final ObjectProperty<EventHandler<Event>> onShowingProperty()
onShownPropertyback to summary
public final ObjectProperty<EventHandler<Event>> onShownProperty()
setCloseButtonVisibleback to summary
public final void setCloseButtonVisible(boolean value)

Sets whether the close button in NotificationPane should be visible.

setContentback to summary
public final void setContent(Node value)

Set the content to be shown in the scene, that is not within the notification bar.

setGraphicback to summary
public final void setGraphic(Node value)

Sets the Node to show within the popup notification bar.

setOnHiddenback to summary
public final void setOnHidden(EventHandler<Event> value)

Called just after the NotificationPane has been hidden.

setOnHidingback to summary
public final void setOnHiding(EventHandler<Event> value)

Called just prior to the NotificationPane being hidden.

setOnShowingback to summary
public final void setOnShowing(EventHandler<Event> value)

Called just prior to the NotificationPane being shown.

setOnShownback to summary
public final void setOnShown(EventHandler<Event> value)

Called just after the NotificationPane is shown.

setShowFromTopback 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.

setShowingback to summary
private final void setShowing(boolean value)
setTextback to summary
public final void setText(String value)

Sets the text to show within the popup notification bar that appears on top of the content.

showback to summary
public void show()

Call this to make the notification bar appear on top of the content of this NotificationPane. If the notification bar is already showing this will be a no-op.

showback to summary
public void show(final String text)

Shows the NotificationPane with the content and text property set, but no graphic property set, and no actions specified.

Parameters
text:String

The text to show in the notification pane.

showback to summary
public void show(final String text, final Node graphic)

Shows the NotificationPane with the content, text and graphic properties set, but no actions specified.

Parameters
text:String

The text to show in the notification pane.

graphic:Node

The node to show in the notification pane.

showback to summary
public void show(final String text, final Node graphic, final Action... actions)

Shows the NotificationPane with the content, text and graphic property set, and the provided actions copied into the actions list.

Parameters
text:String

The text to show in the notification pane.

graphic:Node

The node to show in the notification pane.

actions:Action[]

The actions to show in the notification pane.

showFromTopPropertyback 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.

Returns:BooleanProperty

A property representing where the notification bar should appear from.

showingPropertyback 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 show() and hide() methods.

Returns:ReadOnlyBooleanProperty

A property representing whether the notification bar is currently showing.

textPropertyback 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 content that is within the NotificationPane.

Returns:StringProperty

A property representing the text shown in the notification bar.

updateStyleClassesback to summary
private void updateStyleClasses()

* Private Implementation * *