动作事件监听器
public class SimpleEvent extends JFrame{ private JButton jb = new JButton("我是按钮,单击我"); public SimpleEvent() { // TODO Auto-generated constructor stub setLayout(null); Container cp = getContentPane(); cp.add(jb); jb.setBounds(10,10,100,30); jb.addActionListener(new jbAction()); setVisible(true); setSize(300,300); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } class jbAction implements ActionListener{ @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub jb.setText("我被单击了"); } } public static void main(String[] args) { // TODO Auto-generated method stub new SimpleEvent(); } }