permaculture playing cards
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

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

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);
I agree. Here's the link:
subject: JTables and JScrollPanes
It's not a secret anymore!