JAVA SWING - MVC Pattern

Dear Sirs,

I am trying to design my application to meet as much as possible the MVC pattern.
I am comfortable with the view and model sides of it.
I wonder if my implementation of controller make sense. I see the controller as a Listener or a bridge between the model (Data) and the view (UI). Using this understanding I implemented all my Listeners (Action, PropertyChanged, etc...) and specific voids, in the controller.
I attached 3 files (model, view, controller), and would appreciate any feedback on how I implemented this.

I looking forward to hearing from you.
CentresController.java
CentresView.java
CentresModel.java
Omer-PitouAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Margaret GreenCommented:
The controller, in MVC, is matter that requires judgment. A controller knows the facts of life in the world -- the model comes from datasources and the view is populated from the model.

How much you put in the model is versus the controller is one aspect of the choices to be made. There is no right answer. A model, as a Data Transfer Object from a database, a POJO, is the simplest. In that case the controller knows about the facts of life, i.e. how to get the data object for the model from the database.

The other end of the spectrum of judgement, is a model that knows the facts of life of interacting with the database. You, along with the object-relational frameworks like Java Persistence and Hibernate, package the database access with the model object.

Likewise, how much knowledge of the model do you put in the view? Elements in a view "map" to fields in a model. Is it the controller, that understands this "mapping" and it fills in the view? Or is it the view that accepts a model and places each model field into the view? Both alternatives are really the two ends of a spectrum.

It is an art.

In general, the most a view can know about the model is how to get the data from the it. It can't know about how to get the data from a cache or a database. In your code, the controller is playing a larger role than it may need to -- placing model field values into the view.

I am impressed with your code. Good luck!
Omer-PitouAuthor Commented:
Thank very much.
I am trying my best to understand this concept, and Java itself as I am only 2 months old in Java.
I am glad you say the controller is a matter that requires judgement.
Margaret GreenCommented:
Over time, the most important thing is to remember the MVC roles while realizing they can end up in less than perfectly clean combinations at implementation. Keep the Model clear of knowledge of the view. Allow the View to know the mapping of the Model data to the view elements at most. How much the controller implementation "bleeds" into the View or the Model is the matter for judgment.

For two months of Java and MVC, your work shines even more in my "view".

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Omer-PitouAuthor Commented:
Thank you Margaret for your advice and encouragement.
Regards
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.