import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
public class demo extends JFrame {
public demo(String t) {
super(t);
Container contentPane=this.getContentPane();
contentPane.setLayout(new FlowLayout());
setBackground(Color.white);
contentPane.add(a1);
contentPane.add(a2);
contentPane.add(a3);
contentPane.add(a4);
contentPane.add(a5);
contentPane.add(a6);
a1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){a4.setText("xu");}
});
a2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){a4.setText("xian");}
});
a3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){a4.setText("yue");}
});
a5.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e) {
a6.setText("yes");
}
});
}
JButton a1=new JButton("demo1");
JButton a2=new JButton("demo2");
JButton a3=new JButton("demo3");
JLabel a4=new JLabel("demo4");
JLabel a6=new JLabel("demo6");
JCheckBox a5=new JCheckBox("demo5",false);
public static void main(String[] args) {
demo beat =new demo("good");
beat.addWindowListener(new WindowAdapter() {
//匿名类用于注册监听器
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
beat.setSize(500,300);
beat.setVisible(true);
}
}