Problem setting JComboBox background in Nimbus
843806May 22 2009 — edited May 26 2009I 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