Results 1 to 2 of 2
  1. #1
    Lowest0ne is offline Member
    Join Date
    Apr 2012
    Rep Power

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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default 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

  1. When do I use SwingWorker?
    By TacoManStan in forum AWT / Swing
    Replies: 8
    Last Post: 10-24-2011, 01:40 AM
  2. SwingWorker
    By 3.14.TR in forum Threads and Synchronization
    Replies: 3
    Last Post: 03-14-2011, 05:53 PM
  3. Using SwingWorker
    By viking90 in forum New To Java
    Replies: 1
    Last Post: 04-24-2010, 10:17 AM
  4. SwingWorker Opinions
    By frejon26 in forum AWT / Swing
    Replies: 3
    Last Post: 04-13-2009, 09:41 PM
  5. swingworker
    By musiigedeo in forum AWT / Swing
    Replies: 1
    Last Post: 07-26-2007, 01:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts