how-to

Window (swing) applications

How to add items to JComboBox

Adding new items into JComboBox:

/* -- add three items */

jComboBox1.addItem( "Item 1" );
jComboBox1.addItem( "Item 2");
jComboBox1.addItem( "Item 3");

/* -- select "Item 2" */

jComboBox1.setSelectedItem( "Item 2" );

It shows: