It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes JTableHeader not showing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTableHeader not showing" Watch "JTableHeader not showing" New topic
Author

JTableHeader not showing

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

This is my first experience using a JTable, and I'm using a DefaultTableModel. What do I need to do to get the header to show?

In the test code below, I've gotten to the point of setting the header value (I think), but I'm stuck after that. I'm sure this is something simple, but I'm missing it.



"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If I'm not mistaken, you only get the column headings if your JTable is in a JScrollPane. Yours isn't, it's in a JPanel that's in the JScrollPane. The intermediate panel looks unnecessary to me.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Sure enough, that seems to be it! Thanks for the help.

I broke this out of a much larger piece of code to isolate the problem, and there are a still some unnecessary pieces here. I see I was headed down the wrong path with the code I had in bold.
 
wood burning stoves
 
subject: JTableHeader not showing
 
Similar Threads
Cannot uncheck JCheckBox in JTable
JTable Columns
JTable with RadioButton Headers
Jtable
MultiComponent JTable