This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disable items on JComboBox

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Remus
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic