package jj;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class fucheckbox extends JFrame{
JComboBox cbxBox1,cbxBox2;
String cityname[]= {"北京","上海","奉新","江西",};
public fucheckbox() {
super("组合框");
Container con=getContentPane();
// TODO Auto-generated constructor stub
con.setLayout(new FlowLayout());
con.setBackground(Color.red);
cbxBox1=new JComboBox<>(cityname);//不用指定类型,因为cityname已经指定了类型
cbxBox1.setSelectedIndex(3);
cbxBox2=new JComboBox<>(cityname);//不用指定类型,因为cityname已经指定了类型
// cbxBox2.setSelectedIndex(3);
cbxBox2.setSelectedItem(cityname[1]);
cbxBox2.addItem(new String("长沙"));
cbxBox2.setEditable(true);
con.add(cbxBox1);
con.add(cbxBox2);
pack();
setVisible(true);
}
public static void main(String[] args) {
fucheckbox cc=new fucheckbox();
cc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}