I am having trouble setting the default value in a JComboBox. When I do nothing, the default is the first index (0) in the list. However, when I use setSelectedItem, the value shows up as "..." rather than the item specified (that string is not in my list). Am I misunderstanding what setSelectItem does and perhaps using the wrong method?
There are no new questions, but there may be new answers.
posted 6 years ago
Thanks for the reply but I don't know how practical it would be to write an SSCCE that is sufficiently representative. However, here is the actual code I am using plus some additional behavior I have since found.
The values for the ComboBox are an ArraList from a SQL query so I need to change it to an array of strings. All this works fine, including the JComboBox until I try to setSelectedItem as the default. As I said previously, the box then shows the default value as "..." which is not one of the strings in the array. In addition, I cannot select any value in the JFrame when the JComboBox is displayed. That is, no matter what I select, the display remains "...". The value or item returned by the JComboBox is always 0 or the 0th item which is not the correct index for setSelectedItem. Hopefully that is sufficient to help you get me on the right track or at least suggest some debug technique.