我声明了两个数组,并将它们初始化为字段声明:以下是示例:
final String[] columnNames = {"First Name","Last Name","Sport","# of Years","Vegetarian"};
final Object[][] data = {
{"Mary", "Campione","Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml","Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath","Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour","Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne","Pool", new Integer(10), new Boolean(false)}
};
然后将jTable拖放到Frame中。然后转到表属性>模型>自定义代码,我在那里编写以下代码:
new DefaultTableModel(data, columnNames)
当我运行应用程序时,工作正常。但是这样,我无法在 Netbeans 的设计视图中查看它。
告诉我!为什么即使我在属性中使用以下代码访问数组,设计视图也无法查看它
new DefaultTableModel(data, columnNames)