class test {
public static void main( String args[] ) {
JFrame F = new JFrame();
F.setSize(500,100); F.setTitle("Test");
String[] col = {"Count", "Name", "Company"};
String[][] data = {
{"1", "A", "A123"},
{"2", "B", "B123"}
};
JTable T = new JTable(data, col);
JPanel topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
topPanel.add(T, BorderLayout.WEST);
Container C = F.getContentPane();
C.add(topPanel);
F.setVisible(true);
}
}
06-01-2004, 06:42 AM
rosealapatt
Add a scrollpane. The headers will appear. If you dont want to use a scrollpane, you'll have to use the getTableHeader() method.
Add this to your code. Should work.
JScrollPane scrollpane = new JScrollPane(T);
topPanel.add(scrollpane, BorderLayout.WEST);