我有一个
Java应用程序,当按下红叉时,它会缩小到系统托盘中.
每当发生这种情况时,我会显示一条消息,通知用户应用程序仍在系统托盘中运行.@H_301_3@
... @Override public void windowClosing(WindowEvent e) { try { tray.add(trayIcon); trayIcon.displayMessage("","The application has been reduced in the system tray,to stop it,press the \"Quit\" button",TrayIcon.MessageType.WARNING); setVisible(false); } catch (AWTException ex) { System.out.println("unable to add to tray"); } } ...
我想设置一个计数器,这样即使没有做任何事情,消息也会在几秒后淡出.@H_301_3@
有没有人知道一个很好的方法,因为我似乎无法找到任何现有的方法.@H_301_3@
编辑@H_301_3@
我必须纠正我的问题,事实上,经过一段时间的测试后,它会在7-8秒之后自动消失,但我觉得它有点太长了.此外,它只会在用户执行操作(移动鼠标或在键盘上键入)时消失@H_301_3@
所以新的问题是:有没有办法减少淡出时间并通过配置Java应用程序来改变消息行为,还是Windows固有的?@H_301_3@
解决方法
So the new question would be : Is there a way to reduce the fade out
time by configuring the Java application or is it inherent to Windows?@H_301_3@
> MSDN says in part How long to notify – 在Windows Vista及更高版本中,通知将显示固定的9秒持续时间.
>任何更改都可以仅在Windows大小上维护,但似乎对所有消息都有效/适用@H_301_3@
>你可以创建自己的Traslucent JDialog(透明度可能也是这样)以编程方式放置在左下角,淡出将从Swing Timer调用@H_301_3@