JDK-6285881 : JTrayIcon: support Swing JPopupMenus for tray icons
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86,itanium
  • Submitted: 2005-06-15
  • Updated: 2024-06-03
  • Resolved: 2024-03-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
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
This is exactly the same request as JDK-6575405: support for JPopupMenu instead of java.awt.PopupMenu.
25-03-2024

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).
05-05-2006

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