|
|
|
|
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.
|
|

04-01-2008, 12:36 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 4
|
|
|
[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!
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
}
}
|
|

04-01-2008, 01:05 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,532
|
|
I think you use JFrame form in a IDE? So use a reference to the current object.
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)
|
|

04-01-2008, 03:18 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 4
|
|
|
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, 04:43 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,532
|
|
|
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)
|
|

04-02-2008, 09:56 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 4
|
|
|
I've just tried that - no success. Any other ideas?
|
|

04-07-2008, 02:59 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 4
|
|
|
I think I have to accept that it just do not work on Linux (Gnome).
Thank you all anyway!
|
|

04-07-2008, 03:14 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,532
|
|
|
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)
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
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