File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTableHeader not showing

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic