Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable woes

 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a "Swing" guy so I'm struggling with something that should be very basic and easy. I am creating a JTable using a DefaultTableModel and a DefaultTableColumnModel that I build myself (contains 14 columns). I don't feel like I should need to create a custom TableModel implementation - I just want a very basic table that will store results from a db query.

The code snippets are this:

Right after I do the addRow() (which works) and it attempts to repaint the table, i get this exception:

I'm sure this is something stupid and basic but I can't figure it out. The API seems confusing because there seems to be a dozen ways of configuring the table's columns.

Any help is appreciated. Thanks
 
Venkatraman Kandaswamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a fireTableDataChanged on the tablemodel after adding the row.

If this does not work, get the records from the database again and recreate the table. - the second solution always worked for me - even though I know that this is not the right solution.

--Venkat
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a fireTableDataChanged on the tablemodel after adding the row
Thanks, tried that but unfortunatetly still got same exception.

I got data to display if I used the JTable(Vector rowData, Vector colNames) constructor. So I guess I'll play around with that more.

Swing is overly complicated
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic