Dave Robbins wrote:so far I can get it to post the messages from the ray tracer when it finishes the job but not as it goes along
so I'm here asking for an explanation of the example code and if I understand it correctly
first off, they pass textArea to task in it's constructor and task calls a function on it
I thought having the worker thread do this was a no no
second, what is the purpose of calling
it looks like that fires a PropertyChangeEvent causing the GUI thread to modify the progress bar
publish
protected final void publish(V... chunks)
Sends data chunks to the process(java.util.List) method. This method is to be used from inside the doInBackground method to deliver intermediate results for processing on the Event Dispatch Thread inside the process method.
third, is the purpose of calling setProgress() to set the value that gets sent to the GUI in the PropertyChangeEvent?
and last, what's up with the overridden function process()?
isn't it writing to the GUI?
didn't we just do that with the publish() function?
# Event Dispatch Thread: All Swing related activities occur on this thread. SwingWorker invokes the process and done() methods and notifies any PropertyChangeListeners on this thread.
- and -
process
protected void process(List<V> chunks)
Receives data chunks from the publish method asynchronously on the Event Dispatch Thread.
so far I can get it to post the messages from the ray tracer when it finishes the job but not as it goes along
Steve
Steve
Consider Paul's rocket mass heater. |