aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JTables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTables" Watch "JTables" New topic
Author

JTables

Mike Southgate
Ranch Hand

Joined: Jul 18, 2003
Posts: 183
Quick general question for some of you more advanced guys. When using JTables do you generally use DefaultTableModel or extend AbstractTableModel and why? I always do the latter.

ms


ms<br />SCJP, SCJD
jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
I like writing my own table model (AbstractTableModel) because it is necessary if you want to display or interact with the table in an "expected manner."

Of course this is just my opinion, however I find that most of my tables are populated with strings, ints, doubles, booleans, etc. I want my doubles displayed to a particular precision. I want my numbers right justified, I want my boolean variables to show up as check marks and not as text, I want my text left justified, etc.

Also, most of my tables are NOT for display uses only. There is typically some user interaction with them. I want to be able to pick and choose which columns are editable. I want a drop down list for some columns and to force numerical entries in others.

The uses of writing your own table model are seemingly endless.
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
Generally I use AbstractTableModel. This is mainly because I usually don't want to use a Vector of Vectors to store my cell value objects.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JTables
 
Similar Threads
JTable switching
Swing JTable
Question regarding Renderers
Jcomponent in JTable cells
JTable customization