enter此代码在按下JTable
(称为gametable
)时调用例程。它工作得很好,但我希望在不需要按下的情况下Action
向上或向下移动时调用它;我无法让它工作。我尝试用 替换,但我无法在桌子上上下移动?JTable
enterVK_ENTER
VK_UP
KeyStroke enter = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0);
gameTable.getJTable().unregisterKeyboardAction(enter);
gameTable.getJTable().registerKeyboardAction(new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
synchronized (this) {
gotoGame(gameTable.getSelectedIndex());
}
}
}, enter, JComponent.WHEN_FOCUSED);
我想不通。有人能帮我吗?