|
-
Mar 24th, 2008, 09:05 PM
#1
Thread Starter
PowerPoster
[RESOLVED] 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 Java documentation explain, I believe my code is correct. Then why this is happened on Linux. Somebody can give me a hint.
Thanks.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|