1
我聲明兩個陣列和初始化它們放入字段聲明:下面就是例子:不要以查看設計視圖 - NetBeans的
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中。然後去表格屬性>模式>自定義代碼,並有我寫了下面的代碼:
new DefaultTableModel(data, columnNames)
當我運行應用程序,以這種方式工作fine.But,我沒有得到在觀看它Netbeans的設計視圖。
更新我!爲什麼設計視圖不明白,查看它甚至我用下面的代碼屬性來訪問陣列
new DefaultTableModel(data, columnNames)