import javax.swing.*;
import javax.swing.table.*;
public class Main {
public void start() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTable table = new JTable(new TestTableModel());
frame.add(table);
frame.pack();
frame.setVisible(true);
return;
}
private class TestTableModel extends AbstractTableModel {
public Object getValueAt(int rowIndex, int columnIndex) {
return rowIndex * columnIndex;
}
public int getColumnCount() {
return 7;
}
public int getRowCount() {
return 7;
}
}
public static void main(String[] args) {
new Main().start();
}
}
结果运行出来之后没有表头(就是可以用鼠标调整列宽的那行),请问是怎么回事呢?