Removing all Items from a combo box in Java

前端 未结 9 1194
自闭症患者
自闭症患者 2021-02-06 11:04

I need to remove all items from the combo box

    int itemCount = combo.getItemCount();

    for(int i=0;i

        
9条回答
  •  心在旅途
    2021-02-06 11:12

    Use this to remove all the elements from the combo box :

    DefaultComboBoxModel model = (DefaultComboBoxModel) ComboBox.getModel();
    model.removeAllElements();
    

提交回复
热议问题