This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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