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 How do I disable some of the elements in my 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 "How do I disable some of the elements in my JComboBox?" Watch "How do I disable some of the elements in my JComboBox?" New topic
Author

How do I disable some of the elements in my JComboBox?

Amit Rosner
Greenhorn

Joined: Dec 03, 2001
Posts: 22
Hi,

I want to enable/disable items in my JComboBox selectively.
How do I do that?

Amit.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
1. Define your own ComboBoxModel. You could subclass DefaultComboBox model, adding methods isItemDisabled and setItemDisabled, and override method setSelectedItem.
2. You probably want disabled items rendered differently. Define your own ListCellRenderer.


There is no emoticon for what I am feeling!
Amit Rosner
Greenhorn

Joined: Dec 03, 2001
Posts: 22
Hi,

I'm having some difficulties with your suggestions...
Can you please give me a working example?

Thanks in advance,
Amit.
[ January 24, 2006: Message edited by: Amit Rosner ]
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
My hints were explicit, and here at JavaRanch the emphasis is on teaching folks to fish, not giving them a fish, or something like that...

When you tried to follow the suggestions what went wrong?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I disable some of the elements in my JComboBox?
 
Similar Threads
check if JcomboBox is contain string
smoothing fonts
Keyboard Navigation
JComboBox disabling not Successfull
JComboBox Problem...Help