Thursday May 21, 2009
org.openide.awt.NotificationDisplayer
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.
May 21 2009, 04:52:06 AM PDT Permalink
I found the notification API also very useful and easy to use. See
http://wiki.netbeans.org/FitnessViaPostMortem
which will be integrated for 6.8
Posted by Jaroslav Tulach on May 30, 2009 at 12:46 PM PDT #
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.
Posted by Chris on June 09, 2009 at 06:12 PM PDT #
Don't know. Join the dev@openide.netbeans.org mailing list and ask your question there:
http://openide.netbeans.org/servlets/SummarizeList?listName=dev
Posted by Geertjan on June 15, 2009 at 06:14 AM PDT #
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??
Posted by Richard on July 21, 2009 at 02:23 PM PDT #
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?
Posted by Anderson on August 04, 2009 at 10:46 AM PDT #
anderson: they're both bugs, please file then in issuezilla against Platform/Other
http://www.netbeans.org/issues/enter_bug.cgi?component=platform
thanks
Posted by stan on August 05, 2009 at 02:26 AM PDT #


