This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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?
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).