我有actionPerformed()
做两件事的方法:打印出选中的单选按钮并在另一个类中设置标签的可见性。单击单选按钮时,我无法转换为错误。
public void actionPerformed(ActionEvent e)
{
System.out.println("Selected: " + e.getActionCommand());
JButton hiddenBtn = (JButton) e.getSource();
if (hiddenBtn == submit)
{
Class o = new Class();
o.foo();
}
JButton close = (JButton) e.getSource();
if (close == purchase)
{
System.exit(0);
}
}
我在(JButton) e.getSource()
.