• 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

Should we use DefaultTableColumnModel with TableModel ?

 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The Complete Java2 Certification Study Guide by Roberts, Heller, and Ernest wrote:
... DefaultTableColumnModel provides a standard implementation and includes event "firing" methods that broadcast changes in column behavior --- deletion, addition, order change, selection change, and margin change ... TableModel adds a layer of control on top of column objects, which allows an implementation of the interface to return information on its table --- row count, column count, and column names among them ... One aspect of model-view relationships that may take some getting used to is that the data model representations maintain column order independent of the view. When we want to rearrange data on the view level, for example, we don't want to be restricted to the model's internal arrangement of columns. We may decide we would rather have last names before first names or states before zip codes.



Hi,

I have implemented an MVC architected presentation layer in my SCJD assignment. The problem is that the data that I get from the database is ordered in a String[], and the data in my data model is ordered in the same way. My view is dependent upon the order of the data received from the data model. Did anyone else have this problem, and did you use DefaultTableColumnModel to decouple the view from the data model?

Thanks,
Harry
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Harry,

I just used my own AbstractTableModel. It was simple, easy and type safe: you have to implement a few methods and you can add your own methods (for example an add method which takes a Room-object).
And I think this kind of tableModel is more than enough for this assignment, because there is no need for "deletion, addition, order change, selection change, and margin change" of columns, so if it is not required/needed, don't do it (certainly not when it adds extra complexity in your code).

Kind regards,
Roel
 
Harry Henriques
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel,

The referenced design suggestion seemed like overkill to me, but I wanted to make sure that other designers weren't implementing this "requirement".

Best regards,
Harry
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic