我们可以轻松地将JTable
拖放到netbeans中,但是在属性中看不到任何选项可以更改netbeans中的列标题。
答案 0 :(得分:1)
尝试文档:
https://docs.oracle.com/javase/tutorial/uiswing/components/table.html
这是建议的方法之一:
// The table in SimpleTableDemo.java declares the column names in a String array:
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
// Its data is initialized and stored in a two-dimensional Object array:
Object[][] data = {
{"Kathy", "Smith",
"Snowboarding", new Integer(5), new Boolean(false)},
{"John", "Doe",
"Rowing", new Integer(3), new Boolean(true)},
{"Sue", "Black",
"Knitting", new Integer(2), new Boolean(false)},
{"Jane", "White",
"Speed reading", new Integer(20), new Boolean(true)},
{"Joe", "Brown",
"Pool", new Integer(10), new Boolean(false)}
};
// Then the Table is constructed using these data and columnNames:
JTable table = new JTable(data, columnNames);