aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JTables and JScrollPanes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JTables and JScrollPanes" Watch "JTables and JScrollPanes" New topic
Author

JTables and JScrollPanes

Dave Boden
Ranch Hand

Joined: Nov 08, 2000
Posts: 37
Does anyone know why the headers on a JTable disappear unless you put the table in a JScrollPane? Is this a bug or a "feature"?
Craig Poirier
Greenhorn

Joined: Feb 22, 2001
Posts: 1
I guess you can call it a feature. Read this excerpt from the JTable tutorial:
If you're using a table without a scroll pane, then you must get the table header component and place it yourself. For example:
container.setLayout(new BorderLayout());
container.add(table.getTableHeader(), BorderLayout.NORTH);
container.add(table, BorderLayout.CENTER);
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JTables and JScrollPanes