aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JComboBox focus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox focus" Watch "JComboBox focus" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JComboBox focus