• Post Reply Bookmark Topic Watch Topic
  • New Topic

MVC Question

 
Jianping Wang
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

JTable belong to View as Swing (visual) component.

And element which implements AbstractTableModel belong to Model.

 
Roel De Nijs
Sheriff
Posts: 10763
148
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!