简体   繁体   中英

Changing the ControlShadow color of JComboBoxes only

I've been asked to change the colors of a JComboBox in an application to a very particular, non-default color scheme.

I've found that if I change the value of the

System.UserInterface.Colors.SwingDefaults.ControlShadow

of the Resource Map file from this:

            <Color ident="ControlShadow" value="#999999"/>

to this:

            <Color ident="ControlShadow" value="#FFFFFF"/>

everything looks as it should.

However, I don't want to change the ControlShadow Color for all Swing controls, so I need to find a more focused fix.

Is there a way to change this color for only JComboBoxes?

Note that I tried changing the value of ComboBox.buttonShadow (to #FFFFFF) but this didn't work.

I don't think you should be playing with the resource file.

Check out the UIManager Defaults for a potential way to do this. Look at the "System Colors" to see the default value of the "controlShadow". If you then look at the combo box you will see that the "ComboBox.buttonShadow" has the same value. Maybe you change this value for your LAF. Otherwise you need to create a custom combo box UI. Search the source code to see where this value is used and you will know what to change.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM