aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable woes 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 » Java » Swing / AWT / SWT
Bookmark "JTable woes" Watch "JTable woes" New topic
Author

JTable woes

Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
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


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Venkatraman Kandaswamy
Ranch Hand

Joined: Jul 07, 2004
Posts: 120
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


--Venkatraman<br />SCJP 1.4<br /><a href="http://kvrlogs.blogspot.com" target="_blank" rel="nofollow">blog</a>
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JTable woes