Results 1 to 2 of 2
- 04-20-2012, 12:28 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 21
- Rep Power
- 0
If the SwingWorker atate is DONE, do this... How?
~Gotta love the typo :)~
I've got a lottery program running. You fill in 6 values and click "Play", a SwingWorker generates 6 random numbers and checks them against your picks. It also updates a counter showing basic stats. This behavior continues until you click "Stop". I should add, when you click "Play" every text box that was editable becomes not, and the "Done" button that was disabled becomes enabled. Hit "Done" and the converse. Everything works :).
This is for school, and I would like to implement a "Professor Mode". This mode will break the SwingWorker's DoInBackground() when there are at least 3 matches, sort of a debug to check if the program is working correctly. This part has been simple enough. Now, when the SwingWorker is done via the proffesor mode break, I want all of those non-editables to become editable.
I guess I could pass the buttons to the SwingWorker's constructor, but this seems a little ridiculous. I can get the state of the worker easy enough, but my main issue is that all of my program's functionality is in ActionPerformed(). Since there is no action with the auto-stop, I can't get the state.
Any ideas? Thanks.
-
Re: If the SwingWorker atate is DONE, do this... How?
One way to get the state is to add a PropertyChangeListener to the SwingWorker before excecuting it, and check with the state property is SwingWorker.StateValue.DONE.
Similar Threads
-
When do I use SwingWorker?
By TacoManStan in forum AWT / SwingReplies: 8Last Post: 10-24-2011, 12:40 AM -
SwingWorker
By 3.14.TR in forum Threads and SynchronizationReplies: 3Last Post: 03-14-2011, 04:53 PM -
Using SwingWorker
By viking90 in forum New To JavaReplies: 1Last Post: 04-24-2010, 09:17 AM -
SwingWorker Opinions
By frejon26 in forum AWT / SwingReplies: 3Last Post: 04-13-2009, 08:41 PM -
swingworker
By musiigedeo in forum AWT / SwingReplies: 1Last Post: 07-26-2007, 12:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks