• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable Question

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic