实现ActionListener: class A extends JFrame implements ActionListener public void actionPerformed(ActionEvent e) { int result = Integer.parseInt(t1.getText()) }
类 implements 接口 实现接口 定义的方法
public class MJYS_Frame extends JFrame implements ActionListener { public static void main(String[] args) { MJYS_Frame F = new MJYS_Frame(); F.setLayout(null); { Button B1 = new Button(); B1.setBounds(0, 0, 120, 25); B1.addActionListener(this);// Can not use this in a static context,怎样设置Button的监听? F.add(B1); } // .... }
class A extends JFrame implements ActionListener
public void actionPerformed(ActionEvent e)
{
int result = Integer.parseInt(t1.getText())
}
public class MJYS_Frame extends JFrame implements ActionListener
{
public static void main(String[] args) {
MJYS_Frame F = new MJYS_Frame();
F.setLayout(null);
{
Button B1 = new Button();
B1.setBounds(0, 0, 120, 25);
B1.addActionListener(this);// Can not use this in a static context,怎样设置Button的监听?
F.add(B1);
}
// ....
}