• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting the column headers and refill the data later by DbUtils

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This was done in the constructor, later when a button is pressed, I do,
jTable2.setModel(DbUtils.resultSetToTableModel(db.getSalesByCustomerID(id)));

I made sure that the two models column names matched.
But initially no headers were shown
Thanks
Jack

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the problem you are facing is....?
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:And the problem you are facing is....?



Ha ha forgot, my problem is how can I make the table headers appear initially?
Thanks in advance
Jack
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is DbUtils and what does resultSetToTableModel return?
In other words, TellTheDetails and post your SSCCE
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:
What is DbUtils and what does resultSetToTableModel return?
In other words, TellTheDetails and post your SSCCE



Hi
Hello, resultSetToTableModel maps a simple ResultSet to a JTable. Column by Column.
http://technojeeves.com/joomla/index.php/free/59-resultset-to-tablemodel
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you would need to play with




ResutlSetTableModel == http://stackoverflow.com/q/17846079/714968 (somewhere on net are various type of, search for ... which suits your needs)
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

resultSetToTableModel maps a simple ResultSet to a JTable. Column by Column.



Then you should see a table header if that class works properly. We can't help you debug 3rd party classes if they don't do their job properly.

Invoking the setModel(...) method is all you need to do to refresh data in the table. Of course this method will replace your initial DefaultTableModel including the column names and not just the data.
 
reply
    Bookmark Topic Watch Topic
  • New Topic