NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed. (sponsored)
In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.
Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.
Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Writing desktop applications which are deeply integrated into the desktop from my point of view are hard to implement. I can use Actions and Icons also doing more cool stuff for fancy apps.
The AWT Tray Icon in Java 6 is nice, but i ask my self why it is completely AWT Based?
Take a look at the popup menu for Yahoo Messenger. Now imagine what you could do with a Swing popup menu.
There is something to be said for enabling Swing popup menus for tray icons. The problem is that it is impossible to implement without JDK-side support. The problem is that Swing popup menus refuse to render themselves on top of the "taskbar" so when you right-click on an icon the menu pops many pixels above the actual pop-up position. The problem wouldn't be as bad if Sun somehow enabled Swing popups to render themselves on top of the taskbar if explicitly requested.
Granted this isn't a very compelling use-case but I had one a few months back and I forgot it Hopefully I will recall it soon so I can post it here
This works.. but it throws exceptions, sometimes require two clicks on the icon to close the popup and only works 100% if you click on the JFrame after a popup.
Last I checked (back in Java 5) this had nothing to do with lightweight vs heavyweight but rather JPopupMenu had specific code inside it that ensured that its location would never overlap the taskbar. This is "by design".
Well, may someone from the AWT / Swing Team can say something about that ?
For me it is also an Issue that the Popup will not be in the Look and Feel of the Application. To say it in SUNISH:
I cannot create an Nifty Client !
And for the posted code above: This is no solution as my experience shows often that any dll which is not that nessesary should be avoided as there can be issues on Clients resulting in crashes.
I was disappointed too when I first tried to use the new tray icon feature of Java 6, I wanted nice looking icons in my JPopupMenu until I realized we could only use PopupMenu
I don't know the exact reason why it is now based on AWT, but I saw a bug report about this some time ago. As they explain, there is a work around for it (JPopupMenu displayed over the tray icon), but it is not really great.
> And for the posted code above: This is no solution as
> my experience shows often that any dll which is not
> that nessesary should be avoided as there can be
> issues on Clients resulting in crashes.
Well from this point of view - should we develop software at all However of course I agree that just for such small enhancements native code is a very high price.
Why is Tray Icon AWT Based
At 9:25 AM on Jun 21, 2007, Jens Hohl wrote:
Fresh Jobs for Developers Post a job opportunity
The AWT Tray Icon in Java 6 is nice, but i ask my self why it is completely AWT Based?
11 replies so far (
Post your own)
Re: Why is Tray Icon AWT Based
and why is it an issue that it's AWT based?Re: Why is Tray Icon AWT Based
AWT is a 'OS integration layer'. Java2D, Robot, Printing, Imaging. It's the natural place for TrayIcon.Re: Why is Tray Icon AWT Based
The Popup looks ugly also i cannot use any Action Interface.Re: Why is Tray Icon AWT Based
Take a look at the popup menu for Yahoo Messenger. Now imagine what you could do with a Swing popup menu.There is something to be said for enabling Swing popup menus for tray icons. The problem is that it is impossible to implement without JDK-side support. The problem is that Swing popup menus refuse to render themselves on top of the "taskbar" so when you right-click on an icon the menu pops many pixels above the actual pop-up position. The problem wouldn't be as bad if Sun somehow enabled Swing popups to render themselves on top of the taskbar if explicitly requested.
Granted this isn't a very compelling use-case but I had one a few months back and I forgot it
Gili
Re: Why is Tray Icon AWT Based
i believe this has to do with mixing light weight and heavy weight components.you can force a popup to be a heavy weight component though.
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JPopupMenu.html#setLightWeightPopupEnabled(boolean)
Re: Why is Tray Icon AWT Based
JFC support is broken.. or was never completed.This works.. but it throws exceptions, sometimes require two clicks on the icon to close the popup and only works 100% if you click on the JFrame after a popup.
import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.teppefall.ds.console.Console; import com.teppefall.ds.util.View; public class TestSystemTray { static JFrame owner; static JPopupMenu jfcPopup; public static void main(String[] args) { TrayIcon trayIcon = null; if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); Image image = new ImageIcon(TestSystemTray.class.getResource("/images/teppefall.png")).getImage(); owner = View.asApplication("JFC/SystemTray bug", new JLabel("Press here after popup")); jfcPopup = new JPopupMenu("JFC"); jfcPopup.add(new JMenuItem("Exit") {{ addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Console.info(this, e); System.exit(0); } } ); }}); trayIcon = new TrayIcon(image, "Tray Icon"); trayIcon.setImageAutoSize(true); trayIcon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Console.info(this, e); //System.exit(0); jfcPopup.setVisible(false); } }); trayIcon.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { jfcPopup.setVisible(false); if(e.isPopupTrigger()) { jfcPopup.setInvoker(owner); jfcPopup.setLocation(e.getX(), e.getY()); jfcPopup.setVisible(true); } } public void mousePressed(MouseEvent e) { mouseReleased(e); } }); try { tray.add(trayIcon); //trayIcon.displayMessage("Teppefall", "Says hi !", MessageType.INFO); } catch (AWTException e) { Console.warn(TestSystemTray.class, e); } } else { } } }The setInvoker idea I got from this:
http://weblogs.java.net/blog/ixmal/archive/2006/05/using_jpopupmen.html
Don't know if makes any difference though. The custom imports are from Darkstar:
http://us.teppefall.com/download.jsp
You can also try:
http://jeans.studentenweb.org/java/trayicon/trayicon.html
http://www.jpackages.com/jtray/
https://jdic.dev.java.net/ (as you mentioned)
Re: Why is Tray Icon AWT Based
Last I checked (back in Java 5) this had nothing to do with lightweight vs heavyweight but rather JPopupMenu had specific code inside it that ensured that its location would never overlap the taskbar. This is "by design".Gili
Re: Why is Tray Icon AWT Based
Well, may someone from the AWT / Swing Team can say something about that ?For me it is also an Issue that the Popup will not be in the Look and Feel of the Application. To say it in SUNISH: I cannot create an Nifty Client !
And for the posted code above: This is no solution as my experience shows often that any dll which is not that nessesary should be avoided as there can be issues on Clients resulting in crashes.
- jens
Re: Why is Tray Icon AWT Based
Hi.I was disappointed too when I first tried to use the new tray icon feature of Java 6, I wanted nice looking icons in my JPopupMenu until I realized we could only use PopupMenu
I don't know the exact reason why it is now based on AWT, but I saw a bug report about this some time ago. As they explain, there is a work around for it (JPopupMenu displayed over the tray icon), but it is not really great.
It seems they'll be looking to it:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6285881
Have a nice day.
Re: Why is Tray Icon AWT Based
> And for the posted code above: This is no solution as> my experience shows often that any dll which is not
> that nessesary should be avoided as there can be
> issues on Clients resulting in crashes.
Well from this point of view - should we develop software at all
However of course I agree that just for such small enhancements native code is a very high price.
lg Clemens
Re: Why is Tray Icon AWT Based
I written some small Test Code which fits more my needs to do such Popup with Swing, it is 100% Java 6 based without any dll needed.See http://forum.javacore.de/viewtopic.php?p=33877#33877
for more...
Best regards,
Jens