简体   繁体   English

如何设置Windows通知图标在Java中出现的时间长度

[英]How to set the length of time a windows notification icon appears in Java

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. 我已经制作了一个连接到服务器的Java应用程序以及一个Windows系统任务栏通知弹出窗口,当应用程序断开连接并重新连接时,该弹出窗口会向用户发出警报。 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? 有任何想法吗?

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. 但是您可以自己使用JDialog,JOptionPane或JWindow创建通知,并将其显示在适当的位置。

The icon remains in the system tray until your java programm is closed, or until you remove it yourself. 该图标将保留在系统托盘中,直到关闭Java程序或您自己将其删除为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM