Java

The JComboBox class creates a drop-down list of options that can be displayed to the user as part of a graphical user interface (GUI).

A combo box is a commonly used graphical user interface widget (or control). Traditionally, it is a combination of a drop-down list or list boxand a single-line editable textbox, allowing the user to either type a value directly into the control or choose from a list of existing options by scrolling. Today, the original distinction between a combo box and a drop-down list has often disappeared.
Combo boxes are typically applied to provide autocomplete or autotypefunctionality in a convenient way to the user.
Using the JCreator
//Options for the JcomboBox

String[] fruitOptions = {“Apple”, “Apricot”, “Banana”
        ,”Cherry”, “Date”, “Kiwi”, “Orange”, “Pear”, “Strawberry”};

JcomboBox fruits = new JcomboBox(fruitOptions);

Using NetBeans
Adding an Item in the jComboBox

jComboBox1.addItem("Your Text Here");

Ex.

jComboBox1.addItem("Apple");

The code will allow the jComboBox1 to add an Item

Removing an Item in jComboBox

jComboBox1.removeItem("Item to Remove");

Ex.
jComboBox1.removeItem("Apple");

The code will allow the jComboBox1 to remove an Item

Removing all Items in jComboBox

jComboBox1 .removeAllItems();

The code will allow the jComboBox1 to remove all items

Ex.   Fruits Combobox

Select
Select

Clear
Clear
Remove
Remove
Add
Add

Add Button

jComboBox1.addItem("Apple");
jComboBox1.addItem("Orange");
jComboBox1.addItem("Banana");
jComboBox1.addItem("Grapes");

Selecting an item to display

jtextBox1.setText=jComboBox1.getSelectedItem().toString();

Removing an Item

jComboBox1.removeItem("Orange");

Removing Selected Item

jComboBox1.removeItem(jtxt1.getText());

Removing All items on the jComboBox1

jComboBox1 .removeAllItems();

The if-then and if-then-else Statements

The if-then Statement
The if-then statement is the most basic of all...