0

Hi,
I have a frame with a combobox. the combox is editable. It should show [Select] in its text field when we open the frame but in the drop down, [Select] should not be shown as a drop down item.

Now I have implemented the combobos as:
combo.addItem("Select");
combo.addItem("A");
combo.addItem("B");
and so on...
But the Select is an item and will be shown in the drop down
Can anyone help me plz....

Edited by Ezzaral: Removed illegal drug spam links.

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Ezzaral
0

please edit your 3 posts and remove these spams

are you want to only select some Item in JComboBox

0

my dear the "select" is the one that will always be visible to the user to select an item okay. it will be on index 0;
so declare it as follws:

String[] jbItems = {"---Select---","A","BC","D","E"}
JcomboBox jb = new JCombobox(jbItems);
add(jb);

using the method setSelectedIndex(0); will return the select being visible.


research much on methods like getSelectedITem(); etc thats works with Comboboxes.

0

to remove it u have to use the method

removeItemAt(int index);

you will say:

removeItemAt(0); to remove the item at Index 0.

0

This post was just copied and pasted here for spam purposes. Closing, but leaving intact to preserve the effort of those who answered.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.