Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Swing / AWT / SWT
Can I change the back/foreground color of a disabled JComboBox?
Jose Roel
Greenhorn
Posts: 3
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi!
I need change the background and foreground color when a JComboBox is disabled, is it possible?
Thanks in advance.
Dragan Stankovic
Ranch Hand
Posts: 33
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Yes you can, try:
UIManager.put("ComboBox.disabledBackground", Color.yellow); UIManager.put("ComboBox.disabledForeground", Color.green);
For a complete list of properties you can change in this way try:
http://safari.oreilly.com/0596004087/jswing2-APP-A
[ November 05, 2008: Message edited by: Dragan Stankovic ]
http://www.expertaya.com
Jose Roel
Greenhorn
Posts: 3
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Yes, but this has a problem. I only want to change some JComboBox (my JComboBoxCustom) of the aplication, not all.
Thanks for your time.
Akhshay Ray
Greenhorn
Posts: 11
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Then use a renderer
Michael Dunn
Ranch Hand
Posts: 4632
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
make the comboBox editable
get the editor component (textfield)
use textfield's setDisabledTextColor (inherited from JTextComponent)
Jose Roel
Greenhorn
Posts: 3
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have tried
cbox.setEditable(true);
BasicComboBoxEditor editor = (BasicComboBoxEditor)cbox.getEditor();
cbox.setEnabled(false);
editor.getEditorComponent().setBackground(Color.green); editor.getEditorComponent().setForeground(Color.yellow);
but doesn't work...
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JComboBox: Opaque problem
setting foreground of a disabled text field
How to make JComboBox flash (red color)?
Disabled components
Why ComboBox.disabledForeground not work when set editable?
More...