GeeCON Prague 2014*
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


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);
 
GeeCON Prague 2014
 
subject: JTables and JScrollPanes