简体   繁体   English

通知桌面任务已完成

[英]Notify the desktop that a task has completed

I'm building a Java application with a Swing GUI and a task that takes a lot of time to complete (from 10secs to 10minutes, don't have any real control on the hamsters). 我正在使用Swing GUI和一个需要大量时间才能完成的任务(从10秒到10分钟,对仓鼠没有任何实际控制)来构建Java应用程序。

For now I switch between two JPanel s inside another JPanel which has CardLayout layout manager to say " I'm working " or " I'm done ". 现在我两者之间切换JPanel是另一个里面JPanel具有CardLayout布局管理器说:“ 我的工作 ”或“ 完成 ”。 The switching between panels doesn't notify the desktop that something has changed. 面板之间的切换不会通知桌面某些更改。

Is there any way to notify the operating system that the task has completed? 有什么方法可以通知操作系统任务已完成?

Real world examples: on Windows XP it should make the taskbar button blink, in Mac OSX it should make the dockbar icon jump. 实际示例:在Windows XP上,它应该使任务栏按钮闪烁,在Mac OSX中,它应该使基座栏图标跳转。

Thanks in advance! 提前致谢!

Real world examples: on Windows XP it should make the taskbar button blink, 
in Mac OSX it should make the dockbar icon jump.

Since is possible to notify WindowAdapter , better would be implement todays SystemTray (similair here ), and if Task ended then display Message from status by using TryIcon#displayMessage . 由于可以通知WindowAdapter ,因此最好采用今天的SystemTray此处类似),如果Task结束,则可以使用TryIcon#displayMessage从状态显示Message

在GUI组件中实现Observer界面,并让您的任务扩展Observable

Although the post is a bit old, I guess it should set you on the right track: http://today.java.net/pub/a/today/2003/12/08/swing.html 尽管该帖子有些陈旧,但我认为它应该使您走上正确的路: http : //today.java.net/pub/a/today/2003/12/08/swing.html

It explains how to do what you want using JNI and Mac's alternative JDirect. 它说明了如何使用JNI和Mac的替代JDirect来执行所需的操作。

没有现实世界的答案,但是也许您可以为窗口标题,旧学校风格设置动画

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

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