United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6285881 : JTrayIcon: support Swing JPopupMenus for tray icons

Details
Type:
Enhancement
Submit Date:
2005-06-15
Status:
Open
Updated Date:
2014-03-11
Project Name:
JDK
Resolved Date:
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
itanium,x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
6
Targeted Versions:
6-pool

Related Reports
Duplicate:
Duplicate:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
A DESCRIPTION OF THE REQUEST :
Tray icons in Mustang support showing a PopupMenu.  By allowing to show a Swing JPopupMenu, we get additional features such as menu icons.

A solution would be to create a JTrayIcon class that was a subclass of TrayIcon that added additional constructors to take in a JPopupMenu and perhaps even a custom component for rendering a status message.  The JTrayIcon class could be in the javax.swing package tree, therefore there would be no AWT dependency on Swing.


JUSTIFICATION :
The ability to use a JPopupMenu for tray icons would provide additional functionality such as menu icons.


CUSTOMER SUBMITTED WORKAROUND :
A mouse listener could be registered with the tray icon that shows the JPopupMenu in a new window above the icon, however this involves additional work on the user's part.
###@###.### 2005-06-15 11:19:02 GMT

                                    

Comments
WORK AROUND

Here is a piece of code that can be used to show JPopupMenu from tray icon:

  trayIcon.addMouseListener(new MouseAdapter()
  {
      public void mouseReleased(MouseEvent e)
      {
          if (e.isPopupTrigger())
          {
              jpopup.setLocation(e.getX(), e.getY());
              jpopup.setInvoker(jpopup);
              jpopup.setVisible(true);
          }
      }
  });

However, this will lead to the Java application doesn't shutdown automatically (see 6400183 for details). Another way is to set jpopup's invoker to null, but this also doesn't work (see 6421284 for details).
                                     
2006-05-05
EVALUATION

Definitely something we plan to investigate.
                                     
2005-08-02



Hardware and Software, Engineered to Work Together