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

Problem with updating look and feel colors of swing components dynamically

 
pooja Reddy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am facing a problem in updating look and feel colors of the components dynamically. When i change background color of JButton(key is Button.background), background color of JComboBox, arrows(increment/decrement arrows) of ScrollBar is getting updated.

Below is the code sample i am trying to run:


changeMap contains the changed colors.

Changing ComboBox.background color is not having any effect on the comboboxes. They are simply picking up the button background.
Where as changing ComboBox.foreground color is working absolutely fine. I am able to see the change in combobox text color dynamically.


Am i doing something wrong here? Please let me know your valuable suggestions.
Thank you in advance
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the BasicComboBoxUI


Changing ComboBox.background color is not having any effect on the comboboxes

Do you see the combobox or do you see the renderer?

You might also find Rob Camick's post useful http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/
 
pooja Reddy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i am having a custom renderer for the combo box. It just renders a horizontal line between the elements of combo box.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted the code to highlight that the button in the JComboBox has a ui default property ComboBox.buttonxxx

Yes i am having a custom renderer for the combo box

So you will need to update the L&F of the renderer no?
 
pooja Reddy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried changing "ComboBox.buttonBackground" too. But no luck. Its picking up Jbutton background only.

So you will need to update the L&F of the renderer no?


Can you please elaborate this? Wont calling updateUI() on the component update its UI after the look and feel change?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic