Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JComboBox drop down behavior

843807Apr 16 2010 — edited Apr 19 2010
Hello,

Don't really know what to search to find out the answer, but I think it's trivial and I might have missed something in the API.

I have a combo box:
statusCb = new JComboBox();
statusCb.addItem("Select a state");
statusCb.addItem(status[0]);
statusCb.addItem(status[1]);
statusCb.addItem(status[2]);
statusCb.addItem(status[3]);
statusCb.setSelectedIndex(0);
statusCb.addActionListener(this);
When I click the combo box "Select a state" becomes a selectable item when I don't want it to be:
-----------------------------
Select a State \/
-----------------------------
Select a State
opt1
opt2
opt3
opt4
-----------------------------

Is there a way to stop the selected item from appearing when the combo box drop's down?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2010
Added on Apr 16 2010
11 comments
482 views