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....

Recommended Answers

All 4 Replies

please edit your 3 posts and remove these spams

are you want to only select some Item in JComboBox

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.

to remove it u have to use the method

removeItemAt(int index);

you will say:

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.