You might anyhow have a threading issue: The model is passed to the SpinPanel
on the event dispatch thread. And as far as I can see, there is only one instance of the model. That means that while the Event Dispatch Thread is creating the visualization (that is, executing the code in setModel
), the worker thread might already continue to modify the model.
Regarding the acutal question: You'll need a ChangeListener
to react to changes in any case. The question is: What does to ChangeListener do with the new slider value? According to your description, this can not be passed to the model on the EDT, because the change might interfere with the model currently being updated on the background worker thread. A pragmatic solution could be to pass the new, updated value from the slider directly to the IsingModelTask
, and pass it to the model in the doInBackground
method.