所以我有一些按钮:
static JButton rpsls = new JButton(new ImageIcon(rpslsscaled));
rpslsscaled 是一些图像。所以我试着拿到按钮
public class SomeClass implements ActionListener{
...
static JButton rpsls = new JButton(new ImageIcon(rpslsscaled));
...
class SomeInnerClass implements ActionListener{
...
public void actionPerformed(ActionEvent e){
if (e.getSource() == rpsls) {
JOptionPane.showMessageDialog(null,"You clicked rpsls!");
}
}
}
...
public void actionPerformed(ActionEvent e){
...
}
}
当我按下按钮rpsls
时,什么也没有发生。它不会打印“您点击了 rpsls!”。这是因为这两种actionPerformed
方法吗?