Reputation: 303
I have a JComboBox
which I designed in the Netbeans GUI designer. I have successfully bound the "elements" of the box to an ArrayList<String>
so that the box populates properly. However, it currently automatically displays the first element of the list as the selectedItem
.
I tried to bind the selectedItem
to an int
at first, thinking it would just show the item at the indicated index. No go. I got a ginormous exception that I didn't understand.
Then, I noticed that in the "Binding" window, it said the element had to be an Object
. So, I bound it to a String
, thinking that it would find the element that matched that string and show that element. No dice. Now I'm getting some sort of "PropertyResolutionException
". I've even tried to use an Integer object with the same result.
Any ideas would be appreciated.
Upvotes: 0
Views: 387
Reputation: 205805
Absent your sscce, it's hard to say where things have gone awry. For reference, setSelectedItem()
works as advertised in this example that selects L&F by name.
Upvotes: 1