File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JComboBox not allowing selection from dropdown list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox not allowing selection from dropdown list" Watch "JComboBox not allowing selection from dropdown list" New topic
Author

JComboBox not allowing selection from dropdown list

Farrukh Najmi
Greenhorn

Joined: Jan 29, 2008
Posts: 5

I have a non-editable JComboBox with some pre-configured choices via a model.
The choices display fine in dropdown menu when I click on the JComboBox.
As I move cursor over the choices they get highlighted. However, when I click on a
choice they do not get selected and instead I see the default item stay in the combobox.

What could be the reason why I cannot select from drop down list in my JComboBox?

Note that I am not including any code as my JComboBoxsub-class and its model are fairly
complex.

Thanks for any help.


--Farrukh
Farrukh Najmi
Greenhorn

Joined: Jan 29, 2008
Posts: 5
SOLVED

I determined the cause of the problem. In my JComboBox sub-class I was incorrectly overriding the setSelectedItem(Object) method and not calling super.setSelectedItem(Object) when I should have been.

Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JComboBox not allowing selection from dropdown list