File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes MVC Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "MVC Question" Watch "MVC Question" New topic

MVC Question

Jianping Wang
Ranch Hand

Joined: May 29, 2010
Posts: 60
I recently bought the HeadFirst Design Pattern and SCJD (authored by Monkhouse) and read them carefully. My question is about the model part of MVC. Because JTable has a model, and the M(odel) in MVC is also a model. Should we keep the JTable model in the big Model or keep it in the View? I can see the advantage of keep JTable model in View because when I select a record, I can disable or enable buttons by getting information from JTable model.

SCJP 6 with 93%
Oracle Database SQL Expert with 98%
pete stein

Joined: Feb 23, 2007
Posts: 1561
Perhaps it's the fractal geometry of application design -- there's use of MVC both in the small scale and on the large scale.
Timur Pogorelov

Joined: Jul 07, 2010
Posts: 3

JTable belong to View as Swing (visual) component.

And element which implements AbstractTableModel belong to Model.

Roel De Nijs

Joined: Jul 19, 2004
Posts: 8364

JTable applies also a MVC: the model is represented by an implementation of TableModel (a custom AbstractTableModel or DefaultTableModel). So changing the content of your JTable occurs by passing a new TableModel to the JTable instance (calling method setModel(TableModel tableModel)). And the JTable will update its view.

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
I agree. Here's the link:
subject: MVC Question
jQuery in Action, 3rd edition