| Author |
JComboBox focus
|
Stefan Jansson
Greenhorn
Joined: Sep 20, 2001
Posts: 2
|
|
I have a problem with an editable JComboBox. When I press my EDIT button, but doesn't do any editing in the JComboBox , and then my OK button I want to get the item in the JComboBox. It is ok when an item in the list is visible but if i have an item which i have put there myself, the call getSelectedItem returns null. I have to klick in the field to get the cursor in it and then its ok. What i want is some method to get the cursor in there. I have tried requestFocus but it doesn't work. please help /Stefan
|
 |
Paul Stevens
Ranch Hand
Joined: May 17, 2001
Posts: 2823
|
|
|
It has to be selected for getSelectedItem() to return anything but null. You might look into setSelectedItem() and setSelectedIndex().
|
 |
Stefan Jansson
Greenhorn
Joined: Sep 20, 2001
Posts: 2
|
|
|
Thank you. I called setSelectedItem() with the previus value before I called getSelectedItem() and it works fine. :-D
|
 |
 |
|
|
subject: JComboBox focus
|
|
|