[SOLVED] Windows Linux conflict - TrayIcon image not display in Linux
Hi all,
I have create a TrayIcon and then add image and a pop-up menu into it as follows.
Code:
public void trayIconEventHandling()
{
TrayIcon trayIcon;
if (SystemTray.isSupported()){
SystemTray tray = SystemTray.getSystemTray();
// I have to use this ActionEvent to exit the dialog as well
// Exit from the complete application
ActionListener exitListener = new ActionListener(){
public void actionPerformed(ActionEvent e){
System.out.println("Exiting...");
System.exit(0);
}
};
// Open the dialog in Actionevent
ActionListener openDialogListner = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Open another Dialog here.");
new AboutWindow().setVisible(true);
}
};
// Tray icon menu implimenting goes here
PopupMenu popup = new PopupMenu();
MenuItem defaultItem = new MenuItem("Exit");
MenuItem openDlgItem = new MenuItem("About");
MenuItem extartItem = new MenuItem("Others...");
openDlgItem.setEnabled(false);
defaultItem.addActionListener(exitListener);
openDlgItem.addActionListener(openDialogListner);
popup.add(defaultItem);
popup.add(openDlgItem);
popup.addSeparator();
popup.add(extartItem);
Image image = Toolkit.getDefaultToolkit().getImage("mytrayicon/RADAR.gif");
trayIcon = new TrayIcon(image, "Pop-up", popup);
ActionListener actionListener = new ActionListener(){
public void actionPerformed(ActionEvent e){
System.out.println("Main Dialog!");
// Try to simply call the GUI here
mainWnd.setVisible(true);
}
};
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(actionListener);
trayIcon.addMouseListener(mouseListener);
try
{
tray.add(trayIcon);
}
catch (AWTException e)
{
System.err.println("TrayIcon could not be added.");
}
}
else{
System.err.println("System tray is currently not supported.");
}
}
My code working well on Windows, loaded the image correctly. But in Linux it don't.
As far as I know about Java, I believe my code is correct. Then why this is happened on Linux. Somebody can give me a hint that where I'm going wrong.
Important thing here is, Linux does not give any exception also. :(
Eranga