Results 1 to 10 of 10
- 04-01-2008, 11:36 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
[SOLVED] Problem with setVisible(); on LINUX
Hello,
Could anyone please tell me why the following code does not work on LINUX but on WINDOWS and what I could do to make it work? I have tried so many workarounds but nothing really worked out, I cannot get it visible again - at least not properly! Thank you in advance!
Java Code:private void formWindowIconified(java.awt.event.WindowEvent evt) { [COLOR="Red"]setVisible(false);[/COLOR] } public void SysTray () { final TrayIcon trayIcon; if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); java.net.URL iconUrl = this.getClass().getResource("jack_in_box.gif"); Image image = getToolkit().getImage(iconUrl); MouseListener mouseListener = new MouseListener() { public void mouseClicked(MouseEvent e) { [COLOR="Red"]setVisible(true); setExtendedState(Frame.NORMAL);[/COLOR] } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }; ActionListener exitListener = new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }; PopupMenu popup = new PopupMenu(); MenuItem defaultItem = new MenuItem("Exit"); defaultItem.addActionListener(exitListener); popup.add(defaultItem); trayIcon = new TrayIcon(image, "CheckInBox", popup); trayIcon.setImageAutoSize(true); trayIcon.addMouseListener(mouseListener); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("TrayIcon could not be added."); } } else { // System Tray is not supported } }
- 04-01-2008, 12:05 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I think you use JFrame form in a IDE? So use a reference to the current object.
Should work.Java Code:this.setVisible(false);
- 04-01-2008, 02:18 PM #3
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
Hi Eranga,
Thanks for the quick reply, but the problem is not the reference, the problem is that setVisible(true); in the MouseEvent does not set the JFrame visible again. It just -sometimes- blinks very fast in the panel (Task Bar), looses the focus and stays invisible. Only after I click it a couple of times I get it on the screen again. Oddly enough, it works fine on Windows. Maybe a "paint" problem?!
Thank you for further help
- 04-02-2008, 03:43 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Ah, got the point. Did you try to use an action listener, rather using a mouse listener?
- 04-02-2008, 08:56 PM #5
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
I've just tried that - no success. Any other ideas?
- 04-07-2008, 01:59 PM #6
Member
- Join Date
- Apr 2008
- Posts
- 4
- Rep Power
- 0
I think I have to accept that it just do not work on Linux (Gnome).
Thank you all anyway!
- 04-07-2008, 02:14 PM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I don't think it;s a good idea at all. Better to try different thing there. As much as possible try to get the exceptions and see what it mean. You may have a solution.
Did you try it on formWindowOpened(). If so what happened there.
- 11-22-2008, 01:32 PM #8
Member
- Join Date
- Nov 2008
- Posts
- 2
- Rep Power
- 0
I solved this problem by a dirty workaround
by DwD from jDownloader.orgPHP Code:private void miniIt() { if (guiFrame.isVisible()) { guiFrame.setVisible(false); } else { //Gnome TrayIcon WorkAround guiFrame.setState(JFrame.NORMAL); guiFrame.setVisible(true); guiFrame.setState(JFrame.ICONIFIED); guiFrame.setVisible(false); guiFrame.setState(JFrame.NORMAL); guiFrame.setVisible(true); } }Last edited by DwD; 11-24-2008 at 12:43 PM.
- 11-22-2008, 01:48 PM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You have done the same thing again and again. I don't like that lol.
- 11-22-2008, 04:14 PM #10
Member
- Join Date
- Nov 2008
- Posts
- 2
- Rep Power
- 0
Thats the reason why i call it dirty workaround.
I think the problem is a missing notification if you minimize from the taskbar, thats the reason after
guiFrame.setState(JFrame.NORMAL);
guiFrame.setVisible(true);
the gui is just visible in the panel
after setting the gui state JFrame.ICONIFIED java know the program is iconfied but setVisible(true) if the frame is visible don't have any effect so you have to set visible false first. With JFrame.NORMAL you can restore a iconfied frame. Finaly you have to set visible true.
Similar Threads
-
[SOLVED] Windows Linux conflict - TrayIcon image not display in Linux
By Eranga in forum Advanced JavaReplies: 6Last Post: 04-08-2009, 04:05 AM -
[SOLVED] alignment problem
By nanimtech in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-10-2008, 01:23 PM -
[SOLVED] Actionevent problem
By Cymro in forum New To JavaReplies: 3Last Post: 04-04-2008, 07:11 AM -
Problem locating resources on Linux.
By jimm1 in forum New To JavaReplies: 1Last Post: 01-18-2008, 06:34 PM -
problem with ServerSocket on Linux
By gabriel in forum New To JavaReplies: 1Last Post: 08-07-2007, 04:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks