I know that I can use KeyListener to check if DELETE (char) 127
is pressed or not, but how can I add keyListener to the selectedRow in JTable?
EDIT:
I have tried this but it doesn't work:
myTable.addKeyListener(this);
...
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode() == 127 && myTable.GetSelectedRow() != -1)
{
btnRemove.doClick(); // this will remove the selected row in JTable
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…