Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4310333
Votes 1
Synopsis API to add a java program to a system's app-launching panel/toolbar
Category java:classes_awt
Reported Against 1.2.2 , 1.4.1 , 1.4.2 , hopper-rc
Release Fixed mustang(b38)
State 10-Fix Delivered, request for enhancement
Priority: 4-Low
Related Bugs 6271569 , 4767462 , 4915908 , 4737770
Submit Date 05-FEB-2000
Description




java version "1.2"
Classic VM (build JDK-1.2-V, native threads)

Some Desktops (KDE, MS Windows) have panels/toolbars providing fast access to programs. Some
programs can dock into these panels, to add functionality to the user's basic configuration. An example is the ICQ-Client.

Java should allow the possibility of adding an icon to such a panel,  and providing access to the
functionality the icon provides/represents.

If the platform does not have such a panel/toolbar, the API methods should throw an
exception.

If the Java API contains such a functionality, it would be possible to write
applications in Java, that can dock to the panel :-)
(Review ID: 100731) 
======================================================================
Work Around
N/A
Evaluation
Fix in Tiger

Fixed in mustang.
  xxxxx@xxxxx   2005-04-29 14:24:01 GMT

The new feature provides the following two classes in java.awt package:

-----------------------
public class SystemTray
extends java.lang.Object

The SystemTray class represents the system tray for a desktop. On Microsoft Windows it is referred to as the "Taskbar Status Area", on Gnome it is referred to as the "Notification Area", on KDE it is referred to as the "System Tray". The system tray is shared by all applications running on the desktop.

On some platforms the system tray may not be present or may not be supported, in this case getSystemTray() throws UnsupportedOperationException. To detect whether the system tray is supported, use isSupported().

The SystemTray may contain one or more TrayIcons, which are added to the tray using the add(TrayIcon) method, and removed when no longer needed, using the remove(TrayIcon). TrayIcon consists of an image, a popup menu and a set of associated listeners. Please see the TrayIcon class for details.

Every Java application has a single SystemTray instance that allows the app to interface with the system tray of the desktop while the app is running. The SystemTray instance can be obtained from the getSystemTray() method. An application may not create its own instance of SystemTray.


Here's the methods:

	void		add(TrayIcon trayIcon)
static	SystemTray 	getSystemTray()
	TrayIcon[] 	getTrayIcons()
	Dimension 	getTrayIconSize()
static 	boolean 	isSupported()
	void	 	remove(TrayIcon trayIcon)


---------------------
public class TrayIcon
extends java.lang.Object

A TrayIcon object represents a tray icon that can be added to the system tray. A TrayIcon can have a tooltip (text), an image, a popup menu, and a set of listeners associated with it.

A TrayIcon can generate various MouseEvents and supports adding corresponding listeners to receive notification of these events. TrayIcon processes some of the events by itself. For example, by default, when the right-mouse click is performed on the TrayIcon it displays the specified popup menu. When the mouse hovers over the TrayIcon the tooltip is displayed.

Note: When the MouseEvent is dispatched to its registered listeners its component property will be set to null. (See ComponentEvent.getComponent()) The source property will be set to this TrayIcon. (See EventObject.getSource())

Note: the actions which show a popup menu and select a tray icon are associated with different user gestures.

A TrayIcon can generate an ActionEvent. On some platforms, this occurs when the user selects the tray icon using either the mouse or keyboard. 


Here's the methods:

void 	addActionListener(java.awt.event.ActionListener listener)
void 	addMouseListener(java.awt.event.MouseListener listener)
void 	addMouseMotionListener(java.awt.event.MouseMotionListener
                                       listener)
void 	displayMessage(java.lang.String caption, java.lang.String text,
                       TrayIcon.MessageType messageType)
String 	getActionCommand()
ActionListener[]	getActionListeners()
Image 	getImage()
MouseListener[] 	getMouseListeners()
MouseMotionListener[] 	getMouseMotionListeners()
PopupMenu	 	getPopupMenu()
Dimension 		getSize()
String 	getToolTip()
boolean	isImageAutoSize()
void 	removeActionListener(java.awt.event.ActionListener listener)
void 	removeMouseListener(java.awt.event.MouseListener listener)
void 	removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
void 	setActionCommand(java.lang.String command)
void 	setImage(java.awt.Image image)
void 	setImageAutoSize(boolean autosize)
void 	setPopupMenu(java.awt.PopupMenu popup)
void 	setToolTip(java.lang.String tooltip) 

  xxxxx@xxxxx   2005-05-03 13:36:15 GMT
Comments
  
  Include a link with my name & email   

Submitted On 27-APR-2005
tlund_
It looks like JDIC's TrayIcon and SystemTray APIs will be implemented in Mustang.
Great news. I'm really looking forward to this.

I have a request as well.
I know you have modified the JDIC TrayIcon API somewhat, so I'm not sure if you have implemented this already.. Anyway, here it goes: 

In MS Windows, the behaviour when clicking on a tray icon seems to differ a bit with various programs: a single right mousebutton-click usually opens the popupmenu. a single left mousebutton-click can open a different popupmenu (like the 


Submitted On 27-APR-2005
tlund_
continued:

(like the "Safely Remove Hardware" icon in Windows XP), or show the main program frame. A double click usually shows the main frame. 
A common scenario is that a frame can be minimized to the tray (adding the trayicon to the systemtray). A double click on the trayicon shows the frame again, and usually removes the tray icon. 

In other words: all this could be supported by TrayIcon by allowing to add a MouseListener to it. The programmer can then decide what the various mouse events will do. 

This will allow the TrayIcon to have more flexibility.

I have a feeling people will be requesting this feature :)


Submitted On 28-APR-2005
Papa_Smurph
I agree with tlund_, the flexibility of a MouseListener would be quite useful.  Maybe have a default behavior that the developer can override by supplying their own MouseListener, kind of like JFrame's default closing operation.


Submitted On 03-MAY-2005
anton_t
You will not be disappointed about mouse listeners =)


Submitted On 22-MAY-2005
tlund_
awsome. thanks. It seems this will be included in b38 due out on thursday 26th of may. Looking forward to trying out a mustang build for the first time :)


Submitted On 08-JUN-2005
Pepijn Schmitz
It would be very nice if you could also remove your frame's taskbar entry so that you can emulate the behaviour of for instance IM clients and email notifiers, which _only_ have a system tray icon. RFE 6192336 is about this, and should IMHO now also be implemented.


Submitted On 30-AUG-2005
idontusenumbers
The JDIC implementation currently does not support the the alpha channel in Microsoft Windows for TrayIcon. Is support for this already in place or planned or what?


Submitted On 11-SEP-2005
Just tried it under Gnome 2.10/Fedora 4, and it looks good.

However, since I'm a user, I always want more. So I wonder:

Is Swing JPopupMenu support planned? Or if not, what about a method to get the coordinates of the tray icon, so one does not have to be limited to a PopupMenu?


Submitted On 13-SEP-2005
anton_t
to Pepijn Schmitz:
To have a TrayIcon displayed in the system tray you mustn't keep a Frame shown at all. Just add your icon and enjoy =)

to idontusenumbers:
MS Windows itself doesn't  support alpha blending for  Taskbar Status Area icons.

to 11-SEP-2005:
Mustang (J2SE 6.0) will not support JPopupMenu in SystemTray API. Though, you're not limited to an AWT PopupMenu. You're able to listen mouse events on TrayIcon and show anything you like, including JPopupMenu. You may take the coordinates from those mouse events (they are absolute). Windows, unfortunatetly, doesn't provide API to get location of a Status Area icon, that's why there's no method like TrayIcon.getLocation().


Submitted On 09-DEC-2005
kopsaj
To  anton_t: I've just tried and the icons in my WinXP SP2 tray do use alpha channel.


Submitted On 14-DEC-2005
anton_t
to kopsaj: Yes, it seems I was wrong about unability to use alpha channels for taskbar icons. But, to say the truth, I'm not sure I can see the use of this. You can make your whole taskbar  transparent, but what a fun to have a single icon transparent in the taskbar?



PLEASE NOTE: JDK6 is formerly known as Project Mustang