Duplicate :
|
|
Duplicate :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.6.0-rc" Java(TM) SE Runtime Environment (build 1.6.0-rc-b90) Java HotSpot(TM) Client VM (build 1.6.0-rc-b90, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Linux Golgotha 2.6.17-ARCH #1 SMP PREEMPT Tue Jun 20 12:31:51 CEST 2006 i686 Intel(R) Pentium(R) M processor 1.60GHz GenuineIntel GNU/Linux EXTRA RELEVANT SYSTEM CONFIGURATION : KDE version 3.5.3 A DESCRIPTION OF THE PROBLEM : I played around with the new systray feature in Mustang and realized that the icon will not appear in the tray area of KDE. I tried the same program under Windows and Gnome with success. Only KDE has problems displaying the icon. When I start the program the space for the tray icon appears in KDEs Tray but it's empty. The popup menu is also not shown when clicking on the empty space with right mouse button. I realized one time that the icon moved from up to down like pictures scrolling through a screen but I could not reproduce that again. Earlier I tried also Mustang BETA 1 with the same result. I will attach the code I'm using. Keep in mind that javacup.gif which is used by the code is missing but you can take other images as well. For simplicity you can simply take http://chat.ananzi.co.za/javacup.gif which should be the same except of the size maybe. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.AWTException; import java.awt.Image; import java.awt.MenuItem; import java.awt.PopupMenu; import java.awt.SystemTray; import java.awt.Toolkit; import java.awt.TrayIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /* * Created on May 19, 2006 */ public class Systray { /** * @param args */ public static void main(String[] args) { Image image = Toolkit.getDefaultToolkit().getImage("images/javacup.gif"); TrayIcon trayIcon = null; if (SystemTray.isSupported()) { // get the SystemTray instance SystemTray tray = SystemTray.getSystemTray(); // create a action listener to listen for default action executed on the tray icon ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { } }; // create a popup menu PopupMenu popup = new PopupMenu(); // create menu item for the default action MenuItem defaultItem = new MenuItem("test entry"); defaultItem.addActionListener(listener); popup.add(defaultItem); /// ... add other items // construct a TrayIcon trayIcon = new TrayIcon(image, "Tray Demo", popup); trayIcon.setImageAutoSize(true); // set the TrayIcon properties trayIcon.addActionListener(listener); // ... // add the tray image try { tray.add(trayIcon); } catch (AWTException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // ... } else { // disable tray option in your application or // perform other actions } // ... // some time later // the application state has changed - update the image if (trayIcon != null) { trayIcon.setImage(image); } // ... } } ---------- END SOURCE ----------
|