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 Change the background of combobox in disabled mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Change the background of combobox in disabled mode" Watch "Change the background of combobox in disabled mode" New topic
Author

Change the background of combobox in disabled mode

Smriti Anchu
Ranch Hand

Joined: Dec 21, 2004
Posts: 40
Hi all,

How do i change the background color of the combobox to white in disabled mode.

I have used UIManager.put ( "ComboBox.disabledBackground", Color.WHITE );

This is actually making the background color of the combo box to white. But the problem is when i apply this, the background color of the combo box is changed to white throughout the application. I want the color to change to white only in one screen . How do i do this ? Kindly help me in this regard


regards
smriti
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

You'll need to create your own renderer for the JComboBox model. In this renderer class you can tell it to set a background color if the index is disabled.

Here is a tutorial on creating a custom renderer.


GenRocket - Experts at Building Test Data
Smriti Anchu
Ranch Hand

Joined: Dec 21, 2004
Posts: 40
i created a renderer but even then the background is not set to white in disabled mode.

i entered the foll. code in getListCellRenderer method

if (!list.isEnabled) {
setbackground(Color.WHITE)
}
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
is this what you're trying to do?

Smriti Anchu
Ranch Hand

Joined: Dec 21, 2004
Posts: 40
No,
The code is written below:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change the background of combobox in disabled mode
 
Similar Threads
Struts - View html:select
Disabled components
In disabled mode, how do i make JList data to be in black color
CSS: combo-box
Disabling Combo box