File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Disable items on JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Disable items on JComboBox" Watch "Disable items on JComboBox" New topic

Disable items on JComboBox

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Hi. Can anyone help me figure out how I can disable certain items on a JComboBox? I know I need a customer renderer which I am using one for setting tool tips on my items, however, I can't seem to figure out how to disable certain items so the user cannot select them.
Here's my custom renderer:

Thanks for any help!
[ October 01, 2002: Message edited by: Jennifer Sohl ]
Remus Stratulat

Joined: Jan 29, 2002
Posts: 14
I don't know exactly how you can do it but here is what I think.
Search in the JComboBox's ActionMap the action responsible with item selection. Save it. Make your own select action that filter the items as you want and for those that satisfy the filter call the saved action, for the others don't. This is along with that custom renderer that you have to mark the disabled items.
Hope it helps,

I agree. Here's the link:
subject: Disable items on JComboBox
jQuery in Action, 3rd edition