import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.*;
public class  JComboBox_test extends JFrame implements ItemListener {
    JComboBox jComboBox1 = new JComboBox();
    JTextField jTextField1 = new JTextField();
    JLabel jLabel1 = new JLabel("你选择的是");
    public  JComboBox_test() { 
        setLayout(null);
        jComboBox1.setBounds(25, 21, 114, 29);
        jLabel1.setBounds(25, 60, 104, 29);
        jTextField1.setBounds(109, 70, 63, 30);
        jComboBox1.addItem("长春");
        jComboBox1.addItem("北京");
        jComboBox1.addItemListener(this);
        add(jComboBox1);
        add(jLabel1); 
        add(jTextField1);        
    } 
    public static void main(String args[]) {
         JComboBox_test ta = new  JComboBox_test();
         ta.setBounds(200, 300, 250, 160);
         ta.validate();
         ta.setVisible(true);
    }
    public void itemStateChanged(ItemEvent e) {
	 String text=(String)jComboBox1.getSelectedItem();
         jTextField1.setText(text);
    }
}
