4

I've made a java application which connects to a server and a Windows system tray notification popup which alerts the user when the application has disconnected and reconnected. Here is the code:

Image iconDisconnected = new
ImageIcon(this.getClass().getResource(iconDisconnectedLocation)).getImage();
trayIcon = new TrayIcon(iconDisconnected);
trayIcon.displayMessage("caption", "message", TrayIcon.MessageType.INFO);

However, this icon only appears for a few seconds. Is there a way to make it appear for longer? I've tried reading the manual and searching but can't find any information about this. Any ideas?

user1912424
  • 329
  • 3
  • 6
  • I believe that this is up to Windows and Windows user settings (hide inactive icons). In other languages, there probably are methods for keeping an icon active. – Gilbert Le Blanc Dec 18 '12 at 10:05
  • This problem has perpetuated in annoyance since Mac's message lingers until you close it and Windows 8 and Windows 10 messages now slide in by default and play a jingle each time. We've decided to move away from the tray notifications altogether, it's simply a bad experience on the Java platform. – tresf Mar 30 '16 at 14:35

1 Answers1

2

No the messege display depends on your OS. But you can create a notice yourself using a JDialog, JOptionPane or JWindow for example and make it appear in the appropriate location.

The icon remains in the system tray until your java programm is closed, or until you remove it yourself.

Stefan
  • 12,108
  • 5
  • 47
  • 66