JComboBox -- Item is not in the list????????
I have a "dynamic" JComboBox. What I mean by that is items are removed and added on "the fly".
The getSelectedIndex() is returning -1 when an item is selected. I looked this up and it indicates the selected item is not in the list....What in the world does that mean? The item was added to the ComboBox.
One more thing, the getItemCount() does return the correct number of items..So I don't know why I can't get the selected item or get the selected index.
So, can anyone help me with this?
By the way, I've tried adding a revalidate call but that didn't work.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
try getting the model of the combobox and then getting the selected item? i'll check my stuff and see what i do.
Easter Bunny
Junior Poster in Training
57 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
by the way, what does your code for that look like? can't think of anything i did that used comboboxes. did use jlists, but i reckon they should sorta be the same.
Easter Bunny
Junior Poster in Training
57 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
Ok, I've changed what I was doing to JList and that worked out fine. Thank you both for helping me. I'll give rep to you guys for your help.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20