This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes MVC structure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "MVC structure" Watch "MVC structure" New topic
Author

MVC structure

Alex Gregory
Ranch Hand

Joined: Jun 15, 2002
Posts: 46
Hello, I'm a bit confused about MVC for this assignment. My code is finished and all is in one file, the client file. I'm afraid of being failed for not following conventions, so I would really appreciate someone clarifying how MVC works with this:
I have a tabbedPane which has panels for searching and booking
The searching panel has 2 comboboxes and a button to search.
The booking panel has a JTable and a reservation button.
How do I organize this to fit the MVC pattern. I know this is a long post, but i would appreciate your time in this, thanks much in advance.
Rommel Carvalho
Greenhorn

Joined: Mar 27, 2002
Posts: 9
Hi,
This (how to implement MVC) is a really good post that explains it all. Hope it helps.
Rommel Carvaho
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

Also check out this Page describing Model View Controller too.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Alex Gregory
Ranch Hand

Joined: Jun 15, 2002
Posts: 46
Should the buttons be the Controllers, the Table model be the model, and the actual table be the viewer?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

The Controller is a completely seperate class. It knows about the GUI, and it knows about the Model, and handles actions for the GUI, and also passing the Model to the GUI.
Think of a Mailman. Now think of Mail being sent to the Post Office without the sender saying I know exactly who this should go to. Instead the sender has no clue. But the Mailman knows who will be interested in getting the letter. So the Mailman sends the letter to who is interested in it. And maybe there are multiple people out there that would be interested in the letter, so the Mailman makes sure that each and every one of them gets the letter.
The Mailman is the Controller. The Letter could be the "Data", the Sender I would link more to the Model, and the receivers could be different Views/GUI's to display the data.
Or the Mailman is the Controller. The letter is some kind of Action that has occured. In this case the sender is a button on the GUI, it sends the letter. The Mailman sees which button is sending it and does some work to make some data changes, and sends the changes to the Model to change the Data.
Hope that clears some things up, and the analogy is not too far fetched.
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC structure