使用Netbeans时将数据添加到JTable [英] adding data to JTable when working with netbeans
本文介绍了使用Netbeans时将数据添加到JTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用netbeans时如何将数据添加到JTable
. Netbeans的后端代码就是这样的:
How can i add data to JTable
while working with netbeans. Netbeans in it's back code does like this :
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)
2-D对象数组和String数组具有本地访问权限,因此当我想在程序中间时无法使用它进行填充. (在某些功能中)
The 2-D object array and String array have local access , so i can't use to fill it when i want to in the middle of the program. (in some function)
像上表一样,我将在某些功能中添加名称和分支,但是我该怎么做呢?
like in the above table i will be adding name and branch while in some function.But how can i do this ?
任何人都可以告诉我一种方法,以便我可以将数据添加到JTable吗?
Can anyone please tell a way so that i can add data to JTable ?
推荐答案
jTable1.getModel().setValueAt(value, row, column);
这篇关于使用Netbeans时将数据添加到JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文