| Author |
JComboBox.setSelectedItem() doesn't work
|
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
But the code following this, doesn't get those values selected in the JComboBox
What is the mistake here?
|
kunal
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Are you sure the objects you want to set as selected items are a) members of the combo boxes' contents, and b) are equal to a member of those combo boxes, as returned by the equals(Object) method?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
Thanks for your reply Rob.
sae.getClassAdmitted() returns '2', which is in the combo boxes' contents.
b) are equal to a member of those combo boxes, as returned by the equals(Object) method?
I didn't understood this
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
Do you mean to say that sae.getClassAdmitted() returns a char value '2' and that the combo box contains Character objects, one of which contains that value? Or did you mean something else when you put the single quotes around the 2?
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
Sorry, my fault
Actually combo box contains String objects, and the value returned by sae.getClassAdmitted() is of String type, i.e "2".
|
 |
 |
|
|
subject: JComboBox.setSelectedItem() doesn't work
|
|
|