java如何将ActionEvent e与键绑定一起使用?
当我第一次使用ActionListener时,它是与JButtons一起使用的。我们曾经为每个按钮设置ActionCommand(“blah”)。然后,在actionPerformed(ActionEvent e)
中,我们使用了类似于if(e.getActionCommand().equals("blah")) //do something
的东西。但是,对于键绑定,因为我使用的是同一个组件,所以setActionCommand没有意义。ActionEvent现在似乎没用了。你能为actionCommand设置一个键吗
共 (0) 个答案