Skip to main content

Tray Icon under KDE 3.2

6 replies [Last post]
Jens Hohl
Offline
Joined: 2006-02-17
Points: 0

Hi,

i've allready tested the Tray under Windows, where all runs fine, with my own code and also the Webstart demo. Under KDE it seems that nothing runs, my Testapplication crashed, but the Webstart Tray icon demo simply not show any icon in the tray! Whats going on there ?

My linux system is Mandrake 10.1 with kde 3.2 and Java 5.0 (stable), and there is the Stacktrace:
java.lang.UnsatisfiedLinkError: createIconIndirect
at org.jdesktop.jdic.tray.internal.impl.WinTrayIconService.createIconIndirect(Native Method)
at org.jdesktop.jdic.tray.internal.impl.WinTrayIconService.createNativeIcon(Unknown Source)
at org.jdesktop.jdic.tray.internal.impl.WinTrayIconService.updateIcon(Unknown Source)
at org.jdesktop.jdic.tray.internal.impl.WinTrayIconService.addNotify(Unknown Source)
at org.jdesktop.jdic.tray.internal.impl.WinSystemTrayService.addTrayIcon(Unknown Source)
at org.jdesktop.jdic.tray.SystemTray.addTrayIcon(Unknown Source)
at de.nicedezigns.simpleplayer.gui.tray.TrayBuilder.(TrayBuilder.java:84)
at de.nicedezigns.simpleplayer.gui.tray.TrayBuilder.getInstance(TrayBuilder.java:43)
at de.nicedezigns.simpleplayer.gui.common.view.PlayerPanel.(PlayerPanel.java:155)
at de.nicedezigns.simpleplayer.gui.PlayerFrame.setup(PlayerFrame.java:116)
at de.nicedezigns.simpleplayer.gui.PlayerFrame.(PlayerFrame.java:58)
at de.nicedezigns.simpleplayer.gui.PlayerFrame.main(PlayerFrame.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:1098)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1045)
at com.sun.javaws.Launcher.continueLaunch(Launcher.java:896)
at com.sun.javaws.Launcher.handleApplicationDesc(Launcher.java:468)
at com.sun.javaws.Launcher.handleLaunchFile(Launcher.java:218)
at com.sun.javaws.Launcher.run(Launcher.java:165)
at java.lang.Thread.run(Thread.java:595)
#### Java Web Start Error:
#### null
Exception in thread "Thread-17" java.lang.UnsatisfiedLinkError: eventLoop
at org.jdesktop.jdic.tray.internal.impl.WinSystemTrayService.eventLoop(Native Method)
at org.jdesktop.jdic.tray.internal.impl.WinSystemTrayService$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:595)

Thx,
Jens

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
suzzane
Offline
Joined: 2012-02-10
Points: 0

hi....

i have the following error:

xception in thread "main" java.lang.ExceptionInInitializerError
at web.Tray.<init>(Tray.java:18)
at web.Tray.main(Tray.java:219)
Caused by: java.lang.SecurityException: class "org.jdesktop.jdic.tray.internal.impl.WinSystemTrayService"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:775)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
at java.lang.ClassLoader.defineClass(ClassLoader.java:614)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:125)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:263)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at org.jdesktop.jdic.tray.internal.impl.ServiceManagerStub.getService(Unknown Source)
at org.jdesktop.jdic.tray.internal.ServiceManager.getService(Unknown Source)
at org.jdesktop.jdic.tray.SystemTray.<clinit>(Unknown Source)
... 2 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

when run the Tray.java even after adding the tray.dll to the classpath

can someone help???

file is:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package web;

import org.jdesktop.jdic.tray.*;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.event.*;

public class Tray implements ActionListener, ItemListener {

SystemTray tray = SystemTray.getDefaultSystemTray();
TrayIcon ti;
JFrame frame;
public Tray() {

JPopupMenu menu;
JMenu submenu;
JMenuItem menuItem;
JRadioButtonMenuItem rbMenuItem;
JCheckBoxMenuItem cbMenuItem;

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
if( Integer.parseInt(System.getProperty("java.version").substring(2,3)) >=5 )
System.setProperty("javax.swing.adjustPopupLocationToFit", "false");
menu = new JPopupMenu("A Menu");

// a group of JMenuItems
menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
// menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1,
ActionEvent.CTRL_MASK));
menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
menuItem.addActionListener(this);
menu.add(menuItem);

// ImageIcon icon = new ImageIcon("middle.gif");
ImageIcon icon = new ImageIcon(Tray.class.getResource("images/middle.gif"));

menuItem = new JMenuItem("Both text and icon", icon);
menuItem.setMnemonic(KeyEvent.VK_B);
menuItem.addActionListener(this);
menu.add(menuItem);

menuItem = new JMenuItem(icon);
menuItem.setMnemonic(KeyEvent.VK_D);
menuItem.addActionListener(this);
menu.add(menuItem);

// a group of radio button menu items
menu.addSeparator();
ButtonGroup group = new ButtonGroup();

rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_R);
group.add(rbMenuItem);
rbMenuItem.addActionListener(this);
menu.add(rbMenuItem);

rbMenuItem = new JRadioButtonMenuItem("Another one");
rbMenuItem.setMnemonic(KeyEvent.VK_O);
group.add(rbMenuItem);
rbMenuItem.addActionListener(this);
menu.add(rbMenuItem);

// a group of check box menu items
menu.addSeparator();
cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
cbMenuItem.setMnemonic(KeyEvent.VK_C);
cbMenuItem.addItemListener(this);
menu.add(cbMenuItem);

cbMenuItem = new JCheckBoxMenuItem("Another one");
cbMenuItem.setMnemonic(KeyEvent.VK_H);
cbMenuItem.addItemListener(this);
menu.add(cbMenuItem);

// a submenu
menu.addSeparator();
submenu = new JMenu("A submenu");
submenu.setMnemonic(KeyEvent.VK_S);

menuItem = new JMenuItem("An item in the submenu");
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2,
ActionEvent.CTRL_MASK));
menuItem.addActionListener(this);
submenu.add(menuItem);

menuItem = new JMenuItem("Another item");
menuItem.addActionListener(this);
submenu.add(menuItem);
menu.add(submenu);

// "Quit" menu item
menu.addSeparator();
menuItem = new JMenuItem("Quit");
menuItem.addActionListener(this);
menu.add(menuItem);

// ImageIcon i = new ImageIcon("duke.gif");
ImageIcon i = new ImageIcon(Tray.class.getResource("images/duke.gif"));

ti = new TrayIcon(i, "JDIC Tray Icon API Demo - TrayIcon", menu);

ti.setIconAutoSize(true);
ti.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setVisible(!frame.isVisible());
}
});
ti.addBalloonActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,
"Balloon Message been clicked - TrayIcon", "Message",
JOptionPane.INFORMATION_MESSAGE);
}
});

tray.addTrayIcon(ti);

// Construct the GUI for balloon message.
frame = new JFrame("Show Balloon Message");
frame.getContentPane().setLayout(new BorderLayout());
frame.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);

JPanel topPanel = new JPanel();
topPanel.setBorder(BorderFactory.createEtchedBorder());
topPanel.setLayout(new BorderLayout());
topPanel.add(new JLabel("Caption: "), BorderLayout.WEST);
final JTextField captionField = new JTextField("JDIC TrayIcon");
topPanel.add(captionField, BorderLayout.CENTER);
JPanel typePanel = new JPanel();
final JComboBox typeBox = new JComboBox(new String[]{"INFO", "ERROR", "WARNING", "NONE" });
typePanel.add(new JLabel(" Type:"), BorderLayout.WEST);
typePanel.add(typeBox, BorderLayout.EAST);
topPanel.add(typePanel, BorderLayout.EAST);
frame.getContentPane().add(topPanel, BorderLayout.NORTH);

JPanel messagePanel = new JPanel();
messagePanel.setLayout(new BorderLayout());
messagePanel.add(new JLabel("Message:"), BorderLayout.NORTH);
final JTextArea messageArea = new JTextArea(5, 20);
messageArea.setText("This is a balloon message.\nYou can set the caption, message, \nand message type");
messageArea.setBorder(BorderFactory.createEtchedBorder());
messagePanel.add(messageArea);
frame.getContentPane().add(messagePanel, BorderLayout.CENTER);

JPanel buttonPanel = new JPanel();
final JButton okButton = new JButton("OK");
final JButton cancelButton = new JButton("Cancel");
ActionListener al = new ActionListener(){
public void actionPerformed(ActionEvent e) {
if(e.getSource() == cancelButton)
frame.setVisible(false);
else if(e.getSource() == okButton){
ti.displayMessage(captionField.getText(), messageArea.getText(), typeBox.getSelectedIndex());
}
}
};
okButton.addActionListener(al);
cancelButton.addActionListener(al);
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

// Returns just the class name -- no package info.
protected String getClassName(Object o) {
String classString = o.getClass().getName();
int dotIndex = classString.lastIndexOf(".");

return classString.substring(dotIndex + 1);
}

public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem) (e.getSource());
String s = source.getText();
if (s.equalsIgnoreCase("Quit")) {
System.out.println("Quit menu item selected!");
System.exit(0);
} else {
s = "Action event detected." + "\n" + " Event source: "
+ source + " (an instance of " + getClassName(source) + ")";

System.out.println(s);
}
}

public void itemStateChanged(ItemEvent e) {
JMenuItem source = (JMenuItem) (e.getSource());
String s = "Item event detected." + "\n" + " Event source: "
+ source.getText() + " (an instance of " + getClassName(source)
+ ")" + "\n" + " New state: "
+ ((e.getStateChange() == ItemEvent.SELECTED)
? "selected"
: "unselected");

System.out.println(s);
}

public static void main(String[] args) {
new Tray();
}

}

... 2 more } catch (Exception e) {quot;);

sjsobol
Offline
Joined: 2006-04-02
Points: 0

Doesn't the Linux system tray implementation require Gnome?

armin_chen
Offline
Joined: 2004-09-29
Points: 0

Hi Jens,

To run the TrayIcon WebStart demo on http://javadesktop.org, you have to set JAVA_HOME environment variable. You can do this in a shell console like the following commands:
export JAVA_HOME=/your/java/home
javaws http://javadesktop.org/jdic/demo/TrayIcon/trayicon.jnlp

To run your own code that using TrayIcon API, you also have to set JAVA_HOME, and the path contains the libtray.so or tray.dll has to be add to LD_LIBRARY_PAHT(on linux) or PATH(on windows). (or you can specify the path in the command line via -Djava.library.path=/path/to/libtray.so )

This defect will be fixed in the next release.

Regards.
-Armin

selendic
Offline
Joined: 2006-02-17
Points: 0

Hmmm, I get "Error: Couldn't find per display information". I'm using XOrg6.8-beta server, is that a know behavior?

alexdude
Offline
Joined: 2007-04-18
Points: 0

Hi
I have the same problem.
Did you found out why such error?

justjain4u
Offline
Joined: 2006-06-15
Points: 0

Hi
I getting this type of error in my stacktrace.
please look on this. Your need will bw helpfull for me.

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width
(-1) and height (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Direct
ColorModel.java:999)
at java.awt.image.BufferedImage.(BufferedImage.java:323)
at org.jdesktop.jdic.tray.internal.impl.WinTrayIconService.updateIcon(Un
known Source)
at org.jdesktop.jdic.tray.internal.impl.WinTrayIconService.addNotify(Unk
nown Source)
at org.jdesktop.jdic.tray.internal.impl.WinSystemTrayService.addTrayIcon
(Unknown Source)
at org.jdesktop.jdic.tray.SystemTray.addTrayIcon(Unknown Source)
at com.xyz.deletor.Tray.(Tray.java:110)
at com.xyz.deletor.Tray$3.run(Tray.java:216)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Regards,
Vabhav Jain