【发布时间】:2011-10-25 02:45:57
【问题描述】:
如何在使用 netbeans 时将数据添加到 JTable。 Netbeans 在它的后面代码中是这样的:
jTable1 = new javax.swing.JTable();
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"Name", "Branch"
}
) {
boolean[] canEdit = new boolean [] {
false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
}); // THIS IS THE SNIPPET GENERATED BY NETBEANS
//( I have already created a table using the drag and drop fetaure of netbeans and this is the back snippet generated)
二维对象数组和字符串数组具有本地访问权限,所以当我想在程序中间时无法使用它来填充它。 (在某些功能中)
像上表一样,我将在某些函数中添加名称和分支。但是我该怎么做呢?
谁能告诉我一种方法,以便我可以将数据添加到 JTable 中?
【问题讨论】:
标签: java swing user-interface jtable