This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable Question

 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have implemented the gui such that my controller contains and updates the table model when search data comes back from the server. this is automatically updating my gui table without the gui having to process 'tabledChanged" or any other kind of events. Is this how the table model works?
Thanks,
Aruna.
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have implemented the gui such that my controller contains and updates the table model when search data comes back from the server. this is automatically updating my gui table without the gui having to process 'tabledChanged" or any other kind of events. Is this how the table model works?

Sounds like your table model acts as an application model in your MVC. I would actually have a separate class to be a model, which in turn can call the methods on table model. The reason for that is to make your models coherent: your table model responsibility should only be setting the data in JTable, while your application model responsibility is to implement business logic, such as searchFlights() and bookFlights() methods.
The key here is that all methods of a class (any class) should be on the same level of hierarchy. So if you see a class something like below, something is wrong:

Eugene.
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eugene,
I should have been more descriptive-
I have a View, Controller and a Model for the app.
I have separate classes for TableModel, CellRenderer and CellEditor.
Controller calls the app Model to fetch data from the Server. Then the controller sets data in the TableModel which causes the GUI to update the view.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic