Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable header doesn't show

 
Kate Zoy
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a JTable which is supposed to have headers, but they don't show!
I have:
public String getColumnName( int c ){return headers[c];}
where headers in an array of strings. This function is in my custom model which extends abstractTableModel. I've done this in another part of my code and it works. Why it doesn't work this time is beyond me! Have any ideas?
Thanks!
 
maggie woo
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your problem related to getting a valid value out of the headers array, or that the JTable component in a container is not displaying the headers on the table?
If the first, you may need to post more of your code.
If the second, try putting the JTable in a JScrollPane.
 
Vishal Methi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dear,
The solution of ur problem is that just u have the the tablemodel on JTable and the syntax is
jtable1.setModel(customTableModel);
note . customTableModel is the object of defaulttablemodle or any table model.....
Is it ur solution.
Vishal
 
Kate Zoy
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, turns out I just forgot to put it in a JScrollPane! That is the only line of code different to my other JTables and I didn't even notice! Thanks so much maggie!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic