Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-01-2008, 12:36 PM
Member
 
Join Date: Apr 2008
Posts: 4
lepetitprince is on a distinguished road
[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!

Code:
private void formWindowIconified(java.awt.event.WindowEvent evt) { setVisible(false); } 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) { setVisible(true); setExtendedState(Frame.NORMAL); } 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 } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-01-2008, 01:05 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,532
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I think you use JFrame form in a IDE? So use a reference to the current object.

Code:
this.setVisible(false);
Should work.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 27, 2008)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-01-2008, 03:18 PM
Member
 
Join Date: Apr 2008
Posts: 4
lepetitprince is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-02-2008, 04:43 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,532
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ah, got the point. Did you try to use an action listener, rather using a mouse listener?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 27, 2008)
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-02-2008, 09:56 PM
Member
 
Join Date: Apr 2008
Posts: 4
lepetitprince is on a distinguished road
I've just tried that - no success. Any other ideas?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-07-2008, 02:59 PM
Member
 
Join Date: Apr 2008
Posts: 4
lepetitprince is on a distinguished road
I think I have to accept that it just do not work on Linux (Gnome).

Thank you all anyway!
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-07-2008, 03:14 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,532
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 27, 2008)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] alignment problem nanimtech JavaServer Pages (JSP) and JSTL 1 04-10-2008 02:23 PM
[SOLVED] Actionevent problem Cymro New To Java 3 04-04-2008 08:11 AM
Windows Linux conflict - TrayIcon image not display in Linux Eranga Advanced Java 0 03-25-2008 06:37 AM
Problem locating resources on Linux. jimm1 New To Java 1 01-18-2008 07:34 PM
problem with ServerSocket on Linux gabriel New To Java 1 08-07-2007 05:46 PM


All times are GMT +3. The time now is 07:04 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org