• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable, AbstractTableModel and Table headers...

 
Eric Roy
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Eric Roy
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That certainly dideley did it!
Thanks Michael.
Eric
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic