2

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

For now I switch between two JPanels inside another JPanel which has CardLayout layout manager to say "I'm working" or "I'm done". 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.

Thanks in advance!

Minkiele
  • 1,260
  • 2
  • 19
  • 32

4 Answers4

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

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • That is an alternative, but modern applications like firefox and word make the taskbar icon flash orange when they feel they need the user to pay attention to the application for whatever reason. So as said, it is an alternative you're describing, but not better perse. It depends on the use case. – Pieter Jan 10 '12 at 14:33
  • Although Pieter's [answer](http://stackoverflow.com/a/8803161/455883) is exactly what I was looking for I decided to implement the `SystemTray`, because it was less time consuming. – Minkiele Jan 16 '12 at 08:41
0

Implement the Observer interface in your GUI component, and let your task extend Observable.

Gijs Overvliet
  • 2,643
  • 3
  • 28
  • 35
0

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

It explains how to do what you want using JNI and Mac's alternative JDirect.

Pieter
  • 3,339
  • 5
  • 30
  • 63
  • I found also an alternative implementation [here](http://stackoverflow.com/questions/2773364/make-jface-window-blink-in-taskbar-or-get-users-attention), thanks for the hints by the way. – Minkiele Jan 16 '12 at 08:43
-1

have no real world answer, but maybe you can animate the window title, old school style

user976283
  • 54
  • 3