Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why the columns disappear ?  RSS feed

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • 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 ?

>
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank You.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!