Hello Ike,
Does anyone have or know of a quick example site showing how to implement,
using Swing, an hourglass cursor while something is being processed,
returning to the default cursor afterwards? I know this is a threading
issue.
Thanks, Ike
my English isn't the best, but I'll try it:
I'd suggest to wrap your process within a self-written Command class.
The Command class would notify CommandListeners about CommandEvents. A
CommandEvent may be of one of three different types (e.g. CMD_START,
CMD_STOP, CMD_ABORT).
The Command class notifies it's listeners about command state changes
(notifyStart(), notifyStop(), notifyAbort()) and offers a method run,
that is intended to start your process.
In the Command's run method, you first notify your listeners about the
process-start (notifyStart()). Then you start your process. After your
process is done you call notifyStop. If you catch an exception, call
notifyAbort.
Your Swing-Component only has to implement the CommandListener
interface, which has one method: commandStateChanged( CommandEvent evt )
Now you can do anything within the commandStateChanged-Method: setting
hourclass cursor if the event is of type CMD_START, returning to default
cursor if the event is of type CMD_STOP or CMD_ABORT. Display an alert
box if the event is of type CMD_ABORT and so on.
cheers
Michael