aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problem with updating look and feel colors of swing components dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with updating look and feel colors of swing components dynamically" Watch "Problem with updating look and feel colors of swing components dynamically" New topic
Author

Problem with updating look and feel colors of swing components dynamically

pooja Reddy
Greenhorn

Joined: Jul 16, 2008
Posts: 10
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

Joined: Jul 26, 2007
Posts: 10535
    
    9

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/

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
pooja Reddy
Greenhorn

Joined: Jul 16, 2008
Posts: 10
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

Joined: Jul 26, 2007
Posts: 10535
    
    9

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

Joined: Jul 16, 2008
Posts: 10
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with updating look and feel colors of swing components dynamically