Geertjan's Blog

  • May 21, 2009


Geertjan Wielenga
Product Manager
The question of the day comes from Christopher Chak, from Experian ("Experian is a global leader in consumer and business credit reporting and marketing services and a constituent of the United Kingdom's FTSE 100 index, with revenues in excess of US$4 billion. We support clients in more than 65 countries and employ more than 15,500 people in 38 countries."). Christopher writes the following on the dev@openide.netbeans.org mailing list today:
I'm trying to implement a StatusLineElementProvider in my project. I have managed to get an icon to appear within a JPanel on the status bar. My question: how do I implement a popup 'text bubble' when I mouse over the icon, ie. exactly like the 'text bubble' that appears on the update reminder icon for the IDE?

Well, the answer is that there's a new class in NetBeans Platform 6.7:

That's org.openide.awt.NotificationDisplayer. So there's three different constructors. Here's one of them in action:

public void actionPerformed(ActionEvent e) {
NotificationDisplayer.getDefault().notify("Title 1", icon, "Text 1", new DemoActionListener(), NotificationDisplayer.Priority.HIGH);

Some screenshots. First, if there's one notification:

Possibly, there's more, and then you see this:

So, Christopher, forget your StatusLineElementProvider and just use the NotificationDisplayer instead! In one line, you'll get exactly what you're looking for! For previous releases, you might look for this code in the 6.7 sources and copy them into your own application.

Join the discussion

Comments ( 8 )
  • Jaroslav Tulach Saturday, May 30, 2009

    I found the notification API also very useful and easy to use. See


    which will be integrated for 6.8

  • Chris Tuesday, June 9, 2009

    Hi Geertjan, thanks for the prompt reply and solution! We implemented it like you suggested, but our balloon's come out square-ish. Maybe because its missing some other files? We extracted all notification displayer files to be included in my module, in NB6.5. Any thoughts? Thanks in advance.

  • Geertjan Monday, June 15, 2009

    Don't know. Join the dev@openide.netbeans.org mailing list and ask your question there:


  • Richard Tuesday, July 21, 2009

    I tried using the NotificationDisplayer but it seems as if the main window simply ignored it. I can write a line using StatusDisplayer, but cannot add an icon. Thoughts??

  • Anderson Tuesday, August 4, 2009

    Hi Geertjan,

    I think I found 2 bugs/errors:

    1. In the NotificationDisplayer javadoc, inside the notify method text ( http://bits.netbeans.org/dev/javadoc/org-openide-awt/org/openide/awt/NotificationDisplayer.html ) it is written: "detailsAction - Action to invoke when user click details text or null.", but that is not correct! If I try to pass null to the method, I receive the following error:"NullPointerException: detailsAction cannot be null.";

    2. If I try to use the NotificationDisplayer without selecting the Auto-Update module dependency, then I receive another error, a NullPointerException when trying to load the dismiss icon inside BalloonManager.java. The path for that icon is: "org/netbeans/modules/autoupdate/ui/resources/dismiss_enabled.png";

    Where can I file this bugs?

  • stan Wednesday, August 5, 2009

    anderson: they're both bugs, please file then in issuezilla against Platform/Other



  • Martin Farmer Thursday, May 27, 2010

    Geertjan: We can get the notifications working fine, but we would like to know when the user has "closed" off a notification, so that we can take some action.

    The actionListener only gets called when the user selects the link from the displayed notification.

    When we looked in the source code, we could only find the SimpleNotificationDisplayer implemented, that simply writes to the status line. where is the code for the version that produces the balloons etc, so that we can override/replace it in our run time ?



  • guest Wednesday, November 13, 2013

    Hello Geertjan,

    In agreement with Martin that it is somehow not possible of getting informed about the user manually clearing a notification. However, NotificationDisplayerImpl does have methods addProprtyChangeListener and removePropertyChangeListener that inform subscribers about added/removed notifications. Couldn't these be added as abstract methods to the NotificationDisplayer itself?

    Also, the Notification class itself doesn't come with a clear(int timeInMillis) method to allow users to time-out Notifications. It only comes with the clear() method that clears a Notification immediately.

    Other than that it's quite useful...

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.