当前位置: 技术问答>java相关
请问,下拉框怎样来清空,?
来源: 互联网 发布时间:2015-01-28
本文导语: 我想每次向下拉框添加数据时,它应先清空,我怎么才能做到, 请大家帮忙呀,我的下拉框名子叫;jComboBoxoldname 请大家给我代码呀, | jComboBoxoldname.removeAllItems(); | removeAllItems() | JComboBox jComboB...
我想每次向下拉框添加数据时,它应先清空,我怎么才能做到,
请大家帮忙呀,我的下拉框名子叫;jComboBoxoldname
请大家给我代码呀,
请大家帮忙呀,我的下拉框名子叫;jComboBoxoldname
请大家给我代码呀,
|
jComboBoxoldname.removeAllItems();
|
removeAllItems()
|
JComboBox jComboBoxoldname = new JComboBox();
int count = jComboBoxoldname.getItemCount();
if(count!=0) {
jComboBoxoldname.removeAllItems();
}
jComboBoxoldname.addItem("1");
jComboBoxoldname.addItem("2");
int count = jComboBoxoldname.getItemCount();
if(count!=0) {
jComboBoxoldname.removeAllItems();
}
jComboBoxoldname.addItem("1");
jComboBoxoldname.addItem("2");
|
JComboBox c= new JComboBox();
c.removeAllItems();
c.removeAllItems();