• 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

why the columns disappear ?

 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I developed a simple JTable using the following code. The output is abnormal that it does not have column header row. The three data rows are there though. I figured out that the problem was from "column Model" part. If I skip the "createColModel" step and
just do JTable table = createTable(tableModel); Then I saw everything including data rows and column row.

Can you tell me what's wrong in my "createColModel" part ?

>
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just guessing that the DefaultTableModel uses a DefaultTableColumnModel, supplying the headerValues to that columnModel.
so, on its own (DefaultTableModel) the headers appear.
when you supply your own columnModel, you also need to supply to it (columnModel) the headerValues.

anyway, following changes to createColModel() seems to work OK

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You.
 
reply
    Bookmark Topic Watch Topic
  • New Topic