Results 1 to 7 of 7
- 03-25-2008, 05:37 AM #1
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
[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.
My code working well on Windows, loaded the image correctly. But in Linux it don't.Java 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."); } }
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. :(
ErangaLast edited by Eranga; 03-25-2008 at 05:41 AM. Reason: adding more
- 01-06-2009, 03:17 PM #2
Member
- Join Date
- Jan 2009
- Posts
- 2
- Rep Power
- 0
Eranga, please give some more details.
What desktop/window manager do you use (I just have tested similar code in KDE 3.5.10 and anything gone well) and what Linux distribution it is?
Also, it would be very useful to know what's the version of Java your application is running on, both in Windows and in Linux.
- 01-06-2009, 04:24 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
This is very old thread I've started. Actually the conflict there is not with the coding.
I'm working on the KDE 3.5 as well, with the JDK version 1.6 and I don't remember the minor version of it. I've use the latest at that time.
I've found two reasons effected on this,
- Image size limitation, I cannot use an image around more than 2MB
- *.gif types are not supported. *.png used
- 01-10-2009, 09:58 PM #4
Member
- Join Date
- Jan 2009
- Posts
- 2
- Rep Power
- 0
Eranga, thanks!
You've just saved us (I mean the forum members) some hours of investigation :)
- 01-11-2009, 03:18 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I really like to help everyone through whatever I know.
- 04-07-2009, 08:07 PM #6
Member
- Join Date
- Apr 2009
- Posts
- 3
- Rep Power
- 0
Eranga, i was looking your code, was missing the main, a package mainWnd
and the method AboutWindow(), after that i had problems with a mouselistener but i think it is related with the first error. So i couldnt make it works.
- 04-08-2009, 04:05 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Actually that's a part of an application. There is no main method, it's only about the tray icon handling. What you want to do is, write a simple class and call this method in appropriate place.
Similar Threads
-
open a pdf file in linux
By aparna in forum Advanced JavaReplies: 5Last Post: 06-08-2010, 12:51 PM -
new member need help with linux
By praveena in forum New To JavaReplies: 0Last Post: 01-22-2008, 10:22 AM -
problem with ServerSocket on Linux
By gabriel in forum New To JavaReplies: 1Last Post: 08-07-2007, 04:46 PM -
eclipse in linux
By bbq in forum EclipseReplies: 1Last Post: 07-04-2007, 08:59 AM -
Linux and java
By Alan in forum Advanced JavaReplies: 2Last Post: 05-31-2007, 02:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks