ボタンが押されたときにアクションを実行する Java のメソッドはありますか? キーパッドのボタン '5' を押すと、GUI の説明 '5' でボタンが起動される KeyListener を作成したいので、これが必要です。
編集
私はActionListenerを手に入れました:
public void actionPerformed(ActionEvent event){
if(button.getLabel().equals("1")){
// do something
}
}
とKeyListener
public void keyPressed(KeyEvent e){
if (e.getKeyCode() == VK_NUMPAD1) {
// do what would happen if I pressed the mouse on the button
// I do not know how to execute it thought that it was pressing down the
// button with the label '1 '
}
}