String item[]={"数组元素1“,“数组元素2”,“数组元素3”};
JComboBox comboBox=new JComBoxModel<>(item);
comboBox.setModel(cm);
JButton btn=new JButton(“打印”);
btn.addActionListener(new ActionListener(){
public void actionPerfromed(ActionEvent e){
System.out.println(“选中的索引”+comboBox.getSelectedIndex());//获取选中的索引
System.out.println(“选中的值”);
}
});