this.tModel.insertRow(rowCount,new Object[] {"","","",""});
this.table.setRowSelectionAllowed(true);
this.table.changeSelection(0, 0, false, false);
this.table.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()==KeyEvent.VK_ENTER) {
rowCount = this.table.getSelectedRow() + 1;
tModel.insertRow(rowCount,new Object[]{"", "","",""});
}
}
});
我正在尝试创建一个 jtable,在运行时通过鼠标单击添加行。我已经添加了一个默认行。但我无法在该行上进行选择。我想在按键操作上添加时将选择更改为新添加的行?请提出答案?提前致谢