• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JTable woes

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic