标签:listener 实现 void ati bounds string npe generate blog
//通过内部类实现监听器 public class ActionMonitor extends JFrame { JButton button; public ActionMonitor(){ this.setLayout(null);//布局 this.setSize(500,400);//大小 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置可以关闭 button =new JButton(); button.setBounds(200, 200, 100, 20);//位置和大小 ActionM am=new ActionM(); button.addActionListener(am);//添加监听 this.setVisible(true); this.add(button); //设置可见性 } public static void main(String[] args) { ActionMonitor am= new ActionMonitor(); } class ActionM implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { //TODO Auto-generated method stub } } }
标签:listener 实现 void ati bounds string npe generate blog
原文地址:http://www.cnblogs.com/test1234/p/6852849.html