Java Swing Tutorial - Java JComboBox.removeItemAt(int anIndex)








Syntax

JComboBox.removeItemAt(int anIndex) has the following syntax.

public void removeItemAt(int anIndex)

Example

In the following code shows how to use JComboBox.removeItemAt(int anIndex) method.

//from w w w  . j a v  a 2s . c o m
import javax.swing.JComboBox;

public class Main {
  public static void main(String[] argv) throws Exception {
    String[] items = { "item1", "item2" };
    JComboBox cb = new JComboBox(items);

    cb.removeItemAt(0);
  }
}