怎么能让JComboBox组件即能手动输入又能直接选择下拉框中的值?
来源: 互联网 发布时间:2015-10-22
本文导语: 怎么能让JComboBox组件即能手动输入又能直接选择下拉框中的值? | String[] num = {"8","9","10","11","12","14","16"}; JComboBox jcom = new JComboBox(num); jcom.setEditable(true); jcom.addItemListener(new ItemListener(){ pub...
怎么能让JComboBox组件即能手动输入又能直接选择下拉框中的值?
|
String[] num = {"8","9","10","11","12","14","16"};
JComboBox jcom = new JComboBox(num);
jcom.setEditable(true);
jcom.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent event){
........
}
});
comEditor = jcom.getEditor();
comEditor.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
.......
}
});
jcom.setSelectedItem(num[4]);
JComboBox jcom = new JComboBox(num);
jcom.setEditable(true);
jcom.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent event){
........
}
});
comEditor = jcom.getEditor();
comEditor.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
.......
}
});
jcom.setSelectedItem(num[4]);
|
jcom.setEditable(true);