On Feb 7, 2008 12:18 PM, DOUTCH GARETH-GDO003
> Want to dispatch a long running process from a JButton and while it is
> * release the JButton from it's depressed state
> * update my UI into a 'busy / wait' state
> until the process finishes when I will return my UI into it's normal state.
You need to accomplish four things:
1. Run the job.
2. Prevent the user from requesting any further actions until the job is done.
3. Keep the app responsive and give the user some indication that a
job is running. (Otherwise, the user may simply kill the app.)
4. Let the user understand that his ability to perform actions, etc.
will be restored momentarily when the job is done. (Otherwise, the
user may kill the app.)
This is really a question about Swing (and the application framework,
if you're using one), so you'll get more complete and specific answers
in a forum with that focus. But, for what it's worth from an SWT
user, here's an outline of how to accomplish the four requirements:
1. Run the job in a worker thread.
2. Pop up a modal dialog in the event-dispatching thread.
3. Enable a "busy cursor" and/or show a progress monitor widget in
the modal dialog.
4. Include a "Please wait while..." or "Executing task X..." message
in the modal dialog.
If you are serious about needing to lock users out of the application
(which usually causes more problems than it solves, IMO -- but that's
another topic), you will have to make sure they can't dismiss the
modal dialog and can't interact with the windows behind it. Consult
Swing resources (or the docs for your application framework) for more