Example usage for javax.swing JComboBox JComboBox

List of usage examples for javax.swing JComboBox JComboBox

Introduction

In this page you can find the example usage for javax.swing JComboBox JComboBox.

Prototype

public JComboBox(Vector<E> items) 

Source Link

Document

Creates a JComboBox that contains the elements in the specified Vector.

Usage

From source file:Main.java

public static void main(String[] args) {
    JComboBox<String> my = new JComboBox<>(new String[] { "HELLO WORLD", "java2s.com" });
    JFrame frame = new JFrame("");
    frame.add(my);//from  w w w  .  j a va2  s .  co  m
    frame.pack();
    frame.setVisible(true);
    my.setSelectedIndex(1);
}

From source file:Main.java

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

    cb.setLightWeightPopupEnabled(true);
}

From source file:Main.java

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

    cb.addItem("item3");
}

From source file:Main.java

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

    cb.removeItem("item1");
}

From source file:Main.java

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

    cb.setEnabled(true);//from  www  .  ja  v a  2s.co  m
}

From source file:Main.java

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

    cb.removeItemAt(cb.getItemCount() - 1);
}

From source file:Main.java

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

    cb.hidePopup();//from w w  w  .ja  va  2s  .c o  m
}

From source file:Main.java

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

    cb.removeAllItems();//from  w w w . ja v  a 2  s .c om
}

From source file:Main.java

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

    cb.setPopupVisible(true);/* w w  w .  j av  a2s . c  o  m*/
}

From source file:Main.java

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

    cb.removeItemAt(0);//w  ww .  ja v  a2 s. c  o  m
}