Removing all Items from a combo box in Java

前端 未结 9 1169
自闭症患者
自闭症患者 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:35

    In second line:

    combo.removeItemAt(0);

    I think instead of 0 it should be i.

    do it in reverse order as:

    for(int i=combo.getItemCount()-1;i>=0;i--){
        combo.removeItemAt(i);
    }
    

    But in my case combo.removeAllItems() works fine

提交回复
热议问题