Re: MVC with MouseListener
FWIW Swing is already designed as MVC, its up to you to provide the model/data ;)
I'm not sure I truly understand the question. See if I have this correct - you have a separate thread that manages your data. Why do you need another thread? And is this one thread, or do you launch many?
Going by the example you provided, the goal you wish is to modify the data in the listener class or launch a Thread/SwingWorker to do longer tasks - when that is complete update the UI. So to prevent tight integration between classes (which is one of the fundamental keys of Model-View-Controller) construct your own listener system in your data model. Have the View listen to changes in data and update accordingly. In this way, the controller (eg MouseListener) tells the model to update, the model updates, and when complete the model then tells the view to update. Things can be plugged in and out by adding/removing the appropriate listeners.
See the following for examples: Java SE Application Design With MVC
Re: MVC with MouseListener
Thanks copeg. Your simple explanation of how it works helps alot!
My struggle with MVC was knowing how to implement the listeners and observers, and getting data to flow between them. I found these two simple code examples which fully implement MVC. As usual having actual working code examples are huge. I hope others will find these useful as well....
MVC Pattern
The simplest Model View Controller (MVC) Java example