Java Swing Tutorial - Java JComboBox(Vector < E > items) Constructor








Syntax

JComboBox(Vector < E > items) constructor from JComboBox has the following syntax.

public JComboBox(Vector &lt; E &gt; items)

Example

In the following code shows how to use JComboBox.JComboBox(Vector < E > items) constructor.

//www  .  ja  va 2 s. com
  
import java.util.Vector;

import javax.swing.JComboBox;
import javax.swing.JFrame;

public class Main extends JFrame {
  Main(String title) {
    super(title);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Vector v = new Vector();
    v.add("A");
    v.add("B");
    v.add("C");
    JComboBox jcb = new JComboBox(v);

    getContentPane().add(jcb);

    setSize(200, 50);
    setVisible(true);
  }

  public static void main(String[] args) {
    new Main("Combo box Demo1");
  }
}