aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JTable, AbstractTableModel and Table headers... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JTable, AbstractTableModel and Table headers..." Watch "JTable, AbstractTableModel and Table headers..." New topic
Author

JTable, AbstractTableModel and Table headers...

Eric Roy
Greenhorn

Joined: May 21, 2002
Posts: 4
In my FBN impementation, I decided to extend the AbstractTableModel instead of using the DefaulTableModel because I wanted each row in my Table model to be maintained in a flight data object, holding data related to a flight. So my extended table model maintains a vector of objects, where each object is one row in my table. I implemented the getValueAt( int row, int col) call the proper get method on the row'th element in my vector of objects. I also implemented the getColumnName( int col ) to return a name for each column in my table.
Now the problem... The column headers do not display. Where does the JTable get the names to display in the column headers? Do I have to provide those names to the JTable or should it get them from my table model?
Thanks,
Eric
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Eric,

Now the problem... The column headers do not display. Where does the JTable get the names to display in the column headers? Do I have to provide those names to the JTable or should it get them from my table model?

Try wrapping the JTable in a JScrollPane and the headers should appear. Also, nix the vector for one of the newer Collection classes like ArrayList.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Eric Roy
Greenhorn

Joined: May 21, 2002
Posts: 4
That certainly dideley did it!
Thanks Michael.
Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable, AbstractTableModel and Table headers...