JTable的问题~~
想在某个单元格里面输入数据按ENTER键后触发事件,怎么实现? --------------------编程问答-------------------- 回车触发事件 百度搜索 就是一个方法... --------------------编程问答--------------------JTable.addKeyListener(new KeyListener(){--------------------编程问答--------------------
public void keyReleased(KeyEvent e) {
//判断key是否为enter
}
});
帮我看下这代码好吗,我一在单元格里输入数据就报错
table.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e){
int row,column;
row = table.getEditingRow();
column = table.getEditingColumn();
String password,code;
code = (String)table.getValueAt(row, column);
char[] ch = deciphering(String.valueOf(table.getValueAt(row, 2)));
password = new String(ch);
if (e.getKeyCode()==KeyEvent.VK_ENTER && column==3){
table.setValueAt(password, row, 2);
}
}
}); --------------------编程问答--------------------
帮我看下这代码好吗,我一在单元格里输入数据就报错
table.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e){
int row,column;
row = table.getEditingRow();
column = table.getEditingColumn();
String password,code;
code = (String)table.getValueAt(row, column);
char[] ch = deciphering(String.valueOf(table.getValueAt(row, 2)));
password = new String(ch);
if (e.getKeyCode()==KeyEvent.VK_ENTER && column==3){
table.setValueAt(password, row, 2);
}
}
});
补充:Java , Eclipse