Top Description Inners Fields Constructors Methods
org.controlsfx.control

public Class Notifications

extends Object
Class Inheritance
Imports
impl.org.controlsfx.skin.NotificationBar, java.lang.ref.WeakReference, java.text.MessageFormat, java.util.Arrays, .List, .ArrayList, .LinkedList, .Map, .HashMap, .Objects, .Optional, javafx.animation.KeyFrame, .KeyValue, .ParallelTransition, .Timeline, .Transition, javafx.collections.FXCollections, .ObservableList, javafx.event.ActionEvent, .EventHandler, javafx.geometry.Pos, .Rectangle2D, javafx.scene.Node, .Scene, javafx.scene.image.ImageView, javafx.stage.Popup, .PopupWindow, .Screen, .Window, javafx.util.Duration, org.controlsfx.control.action.Action, org.controlsfx.tools.Utils

An API to show popup notification messages to the user in the corner of their screen, unlike the NotificationPane which shows notification messages within your application itself.

Screenshot

The following screenshot shows a sample notification rising from the bottom-right corner of my screen:

Screenshot of Notifications

Code Example:

To create the notification shown in the screenshot, simply do the following:

Notifications.create()
             .title("Title Text")
             .text("Hello World 0!")
             .showWarning();

When there are too many notifications on the screen, one can opt to collapse the notifications into a single notification using Notifications#threshold(int, Notifications).

Notifications.create()
             .title("Title Text")
             .text("Hello World 0!")
             .threshold(3, Notifications.create().title("Collapsed Notification"))
             .showWarning();

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Notifications.NotificationPopupHandler

Private support classes * *

Field Summary

Modifier and TypeField and Description
private ObservableList<Action>
private Node
private Duration
private boolean
private EventHandler<ActionEvent>
private Window
private Pos
private Screen
private static final String
STYLE_CLASS_DARK

Static fields * *

private List<String>
private String
private int
private Notifications
private String
title

Private fields * *

Constructor Summary

AccessConstructor and Description
private
Notifications()

Constructors * *

Method Summary

Modifier and TypeMethod and Description
public Notifications
action(Action... actions)

Specifies the actions that should be shown in the notification as buttons.

public static Notifications
create()

Call this to begin the process of building a notification to show.

public Notifications
darkStyle()

Specifies that the notification should use the built-in dark styling, rather than the default 'modena' notification style (which is a light-gray).

public List<String>
getStyleClass()

Gets the style classes that would be added to the NotificationBar.

public Notifications
graphic(Node graphic)

Specifies the graphic to show in the notification.

public Notifications
hideAfter(Duration duration)

Specifies the duration that the notification should show, after which it will be hidden.

public Notifications
hideCloseButton()

Specifies that the close button in the top-right corner of the notification should not be shown.

public Notifications
onAction(EventHandler<ActionEvent> onAction)

Specifies what to do when the user clicks on the notification (in addition to the notification hiding, which happens whenever the notification is clicked on).

public Notifications
owner(Object owner)

The dialog window owner - which can be Screen, Window or Node.

public Notifications
position(Pos position)

Specifies the position of the notification on screen, by default it is bottom-right.

public void
show()

Instructs the notification to be shown.

public void
showConfirm()

Instructs the notification to be shown, and that it should use the built-in 'confirm' graphic.

public void
showError()

Instructs the notification to be shown, and that it should use the built-in 'error' graphic.

public void
showInformation()

Instructs the notification to be shown, and that it should use the built-in 'information' graphic.

public void
showWarning()

Instructs the notification to be shown, and that it should use the built-in 'warning' graphic.

public Notifications
styleClass(String... styleClasses)

Specifies the style classes to add to the NotificationBar.

public Notifications
text(String text)

Specifies the text to show in the notification.

public Notifications
threshold(int
The number of notifications to show before they can be collapsed into a single notification.
threshold
,
Notifications
The notification to show when threshold is reached.
thresholdNotification
)

Collapses all the current notifications into a single notification when the number of notifications exceed the threshold limit.

public Notifications
title(String title)

Specifies the title to show in the notification.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionsback to summary
private ObservableList<Action> actions
graphicback to summary
private Node graphic
hideAfterDurationback to summary
private Duration hideAfterDuration
hideCloseButtonback to summary
private boolean hideCloseButton
onActionback to summary
private EventHandler<ActionEvent> onAction
ownerback to summary
private Window owner
positionback to summary
private Pos position
screenback to summary
private Screen screen
STYLE_CLASS_DARKback to summary
private static final String STYLE_CLASS_DARK

Static fields * *

styleClassback to summary
private List<String> styleClass
textback to summary
private String text
thresholdback to summary
private int threshold
thresholdNotificationback to summary
private Notifications thresholdNotification
titleback to summary
private String title

Private fields * *

Constructor Detail

Notificationsback to summary
private Notifications()

Constructors * *

Method Detail

actionback to summary
public Notifications action(Action... actions)

Specifies the actions that should be shown in the notification as buttons.

createback to summary
public static Notifications create()

Call this to begin the process of building a notification to show.

darkStyleback to summary
public Notifications darkStyle()

Specifies that the notification should use the built-in dark styling, rather than the default 'modena' notification style (which is a light-gray).

getStyleClassback to summary
public List<String> getStyleClass()

Gets the style classes that would be added to the NotificationBar.

graphicback to summary
public Notifications graphic(Node graphic)

Specifies the graphic to show in the notification.

hideAfterback to summary
public Notifications hideAfter(Duration duration)

Specifies the duration that the notification should show, after which it will be hidden.

hideCloseButtonback to summary
public Notifications hideCloseButton()

Specifies that the close button in the top-right corner of the notification should not be shown.

onActionback to summary
public Notifications onAction(EventHandler<ActionEvent> onAction)

Specifies what to do when the user clicks on the notification (in addition to the notification hiding, which happens whenever the notification is clicked on).

ownerback to summary
public Notifications owner(Object owner)

The dialog window owner - which can be Screen, Window or Node. If specified, the notifications will be inside the owner, otherwise the notifications will be shown within the whole primary (default) screen.

positionback to summary
public Notifications position(Pos position)

Specifies the position of the notification on screen, by default it is bottom-right.

showback to summary
public void show()

Instructs the notification to be shown.

showConfirmback to summary
public void showConfirm()

Instructs the notification to be shown, and that it should use the built-in 'confirm' graphic.

showErrorback to summary
public void showError()

Instructs the notification to be shown, and that it should use the built-in 'error' graphic.

showInformationback to summary
public void showInformation()

Instructs the notification to be shown, and that it should use the built-in 'information' graphic.

showWarningback to summary
public void showWarning()

Instructs the notification to be shown, and that it should use the built-in 'warning' graphic.

styleClassback to summary
public Notifications styleClass(String... styleClasses)

Specifies the style classes to add to the NotificationBar.

textback to summary
public Notifications text(String text)

Specifies the text to show in the notification.

thresholdback to summary
public Notifications threshold(int threshold, Notifications thresholdNotification)

Collapses all the current notifications into a single notification when the number of notifications exceed the threshold limit. A value of zero will disable the threshold behavior.

Parameters
threshold:int

The number of notifications to show before they can be collapsed into a single notification.

thresholdNotification:Notifications

The notification to show when threshold is reached.

titleback to summary
public Notifications title(String title)

Specifies the title to show in the notification.

org.controlsfx.control back to summary

private final Class Notifications.NotificationPopupHandler

extends Object
Class Inheritance
  • java.lang.Object
  • org.controlsfx.control.Notifications.NotificationPopupHandler

Private support classes * *

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private static final String
private static final Notifications.NotificationPopupHandler
private boolean
private static final double
private ParallelTransition
private final Map<Pos, List<Popup>>
private double
private double
private static final double
private double
private double

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
private Timeline
createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay)

private void
doAnimation(Pos p, Popup changedPopup)

private double
pack-priv static final Notifications.NotificationPopupHandler
private Optional<Screen>
private void
hide(Popup popup, Pos p)

private boolean
private void
private void
setFinalAnchorY(Popup popup, double anchorY)

public void
show(Notifications notification)

private void
show(Window owner, final Notifications notification)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FINAL_ANCHOR_Yback to summary
private static final String FINAL_ANCHOR_Y
INSTANCEback to summary
private static final Notifications.NotificationPopupHandler INSTANCE
isShowingback to summary
private boolean isShowing
PADDINGback to summary
private static final double PADDING
parallelTransitionback to summary
private ParallelTransition parallelTransition
popupsMapback to summary
private final Map<Pos, List<Popup>> popupsMap
screenHeightback to summary
private double screenHeight
screenWidthback to summary
private double screenWidth
SPACINGback to summary
private static final double SPACING
startXback to summary
private double startX
startYback to summary
private double startY

Constructor Detail

NotificationPopupHandlerback to summary
private NotificationPopupHandler()

Method Detail

addPopupToMapback to summary
private void addPopupToMap(Pos p, Popup popup)
createHideTimelineback to summary
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay)
doAnimationback to summary
private void doAnimation(Pos p, Popup changedPopup)
getFinalAnchorYback to summary
private double getFinalAnchorY(Popup popup)
getInstanceback to summary
pack-priv static final Notifications.NotificationPopupHandler getInstance()
getScreenBoundsback to summary
private Optional<Screen> getScreenBounds(Window window)
hideback to summary
private void hide(Popup popup, Pos p)
isShowFromTopback to summary
private boolean isShowFromTop(Pos p)
removePopupFromMapback to summary
private void removePopupFromMap(Pos p, Popup popup)
setFinalAnchorYback to summary
private void setFinalAnchorY(Popup popup, double anchorY)
showback to summary
public void show(Notifications notification)
showback to summary
private void show(Window owner, final Notifications notification)
org.controlsfx.control back to summary

pack-priv Class Notifications.NotificationPopupHandler.CustomTransition

extends Transition
Class Inheritance

Field Summary

Modifier and TypeField and Description
private double
private double
private WeakReference<Popup>

Constructor Summary

AccessConstructor and Description
pack-priv
CustomTransition(Popup popup, double oldAnchorY, double distance)

Method Summary

Modifier and TypeMethod and Description
protected void
interpolate(double frac)

Implements abstract javafx.animation.Transition.interpolate.

The method interpolate() has to be provided by implementations of Transition.

Inherited from javafx.animation.Transition:
getCachedInterpolatorgetInterpolatorgetParentTargetNodeinterpolatorPropertysetInterpolator

Field Detail

distanceback to summary
private double distance
oldAnchorYback to summary
private double oldAnchorY
popupWeakReferenceback to summary
private WeakReference<Popup> popupWeakReference

Constructor Detail

CustomTransitionback to summary
pack-priv CustomTransition(Popup popup, double oldAnchorY, double distance)

Method Detail

interpolateback to summary
protected void interpolate(double frac)

Implements abstract javafx.animation.Transition.interpolate.

Doc from javafx.animation.Transition.interpolate.

The method interpolate() has to be provided by implementations of Transition. While a Transition is running, this method is called in every frame. The parameter defines the current position with the animation. At the start, the fraction will be 0.0 and at the end it will be 1.0. How the parameter increases, depends on the interpolator, e.g. if the interpolator is Interpolator#LINEAR, the fraction will increase linear. This method must not be called by the user directly.

Annotations
@Override