Results 1 to 2 of 2
Thread: SwingWorker progress?
- 11-20-2011, 03:13 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
SwingWorker progress?
Hello,
I would like to know if there is any way to get progress even if I want to keep GUI and core separated.
In the doinBackground() method I call a method from a core class (I load some files and initialize a game). How do I pass the progress to the Worker if time remaining in not known? Or at least I do not know it.
Here is a snippet:
In the GameBegin I call the constructor of the class Game and initialize the whole thing. How do I get progress from the class Game to the main class where the Worker is?Java Code:SwingWorker<String, Object> worker = new SwingWorker<String, Object>() { @Override protected String doInBackground() throws Exception { GameBegin(); return "Start Game"; } ... }; worker.execute();
Thanks for all pieces of advice.
Mirek
-
Re: SwingWorker progress?
Since you don't know the time remaining, I can't see how you'll be able to pass it anywhere. Perhaps you are able to get another surrogate marker of completeness such as bytes or files processed? Otherwise about all that I can see you can do based on the code and information provided is to tell the calling code when the SwingWorker has started and when it has finished, and to do that you could add a PropertyChangeListener to the SwingWorker.
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 question
By cotarelo in forum Threads and SynchronizationReplies: 16Last Post: 03-23-2010, 11:29 AM -
swingworker
By musiigedeo in forum AWT / SwingReplies: 1Last Post: 07-26-2007, 12:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks