Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Change the background of combobox in disabled mode

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Smriti Anchu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this what you're trying to do?

 
Smriti Anchu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,
The code is written below:
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic