This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable header doesn't show Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable header doesn Watch "JTable header doesn New topic

JTable header doesn't show

Kate Zoy
Ranch Hand

Joined: Feb 11, 2004
Posts: 33
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?
maggie woo
Ranch Hand

Joined: Dec 18, 2003
Posts: 35
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

Joined: Jan 14, 2004
Posts: 52
Hi Dear,
The solution of ur problem is that just u have the the tablemodel on JTable and the syntax is
note . customTableModel is the object of defaulttablemodle or any table model.....
Is it ur solution.
Kate Zoy
Ranch Hand

Joined: Feb 11, 2004
Posts: 33
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!
I agree. Here's the link:
subject: JTable header doesn't show
It's not a secret anymore!