Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem setting JComboBox background in Nimbus

843806May 22 2009 — edited May 26 2009
I am having a problem setting the background component of a JComboBox when using the Nimbus L&F. The call to JComboBox.setBackground() changes the background of both the content area and the button. I do not want the background color of the button to be changed. I reviewed a number of similar posts in the forums and found a suggested change that results in the button keeping its original background. The code for the suggested change is shown below:


JComboBox bandComboBox;
...
bandComboBox.setBackground(Color.YELLOW);
// This next line of code changes the background color of the button back to its original value
bandComboBox.getComponent(0).setBackground(UIManager.getColor("control"));

This change did not work for the Nimbus L&F but it did work for the Metal L&F. I really need a solution for the Nimbus L&F. Any suggestions would be greatly appreciated.

I am currently running java 1.6_u13.

Thanks!

Casey
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2009
Added on May 22 2009
2 comments
1,053 views