I'm having one of those days....
The following code compiles and executes without error, but does not display the header for the table. Can anyone tell me why?
package
test;
import javax.swing.*;
public class TableTest extends javax.swing.JFrame {
public TableTest() {
super();
Object[][] testData = {
{"0001", "Kevin"},
{"0002", "Kevin"},
{"0003", "Kevin"},
{"0004", "Kevin"},
{"0005", "Kevin"},
{"0006", "Kevin"},
{"0007", "Kevin"},
{"0008", "Kevin"},
{"0009", "Lili"}
};
String[] colNames = {"CustID", "First Name"};
JTable table = new JTable(testData, colNames);
JScrollPane sp = new JScrollPane(table);
table.setPreferredScrollableViewportSize(new java.awt.Dimension(150, 100));
getContentPane().add(table);
public static void main(String[] args) {
TableTest frame = new TableTest();
frame.pack();
frame.setVisible(true);
}
}