NetBeans Platform Cookbook Chapter 10 03

Notify the User

NetBeans can notify about any event or request (e.g. new updates are available) showing a bubble in the right bottom corner of the main window. It is only informal and does not disturb any work in comparison with a dialog message. If the user ignores it the bubble disappears and only the main important icon is shown with number of these notifications. Try to make yours.


Figure 10.4 Notification bubble


How to

Add the UI Utilities API module into project dependencies.

Retrieve the NotificationDisplayer instance by getDefault() static method. This abstract class is implemented as a service. Is none is available your notification will be displayed in the status line.

This class provides three notify methods:

  • notify(String title, Icon icon, String detailsText, ActionListener detailsAction)
  • notify(String title, Icon icon, String detailsText, ActionListener detailsAction, NotificationDisplayer.Priority priority)
  • notify(String title, Icon icon, JComponent balloonDetails, JComponent popupDetails, NotificationDisplayer.Priority priority)

The title parameter is text shown as a short message or as a tooltip of the icon. The detailsText describes the message. The html tags are not supported here.

If the actionListener parameter is not null the detailed text is underlined as a hyperlink and after click notifies the listener to perform an action.

The priority is given by constants HIGH, NORMAL, LOW, SILENT. By the SILENT priority only an icon is shown. The user can display detail clicking on it.

Passed components have the same meaning as texts.

All these methods return a Notification instance. Its method clear() removes the it from the list.

                "New BBB module available"               // title
              , BBB_ICON, "Load new version of BBB"      // message
              , new LoadBBBActionListener()              // action 
              , NotificationDisplayer.Priority.NORMAL ); // priority


Figure 10.5 Silent notification


Figure 10.6 List of notifications

Notes/Tips documentation

Documentation links:

NotificationDisplayer class

UI Utilities API documentation is on

Notes/Tips sources

You can try and see examples using application in the 10_best / Notification directory.

Text and sources were created under NB 6.8, 6.9, 7.0 and 7.1.


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo