Search code examples
javaswingjradiobuttonuimanager

what do these swing color names mean


Some of the names are clear, like background, foreground, focus etc. But some are just confusing, like light, hightlight, shadow, darkshardow etc. I noticed that these are consistently used in swing UI, so I infer these are part of java's jargon. Does any body know if there is a document out there that explains these names ?

RadioButton.background  
RadioButton.darkShadow  
RadioButton.disabledText    
RadioButton.focus           
RadioButton.foreground  
RadioButton.highlight   
RadioButton.light           
RadioButton.select          
RadioButton.shadow          

Solution

  • These are UIResource elements related to JRadionButton. Each Look & Feel provides different radio button appearance, and may set different defaults for these elements. It is also to up to L&F implementation to use these keys or not.

    For example, here is a method from javax.swing.plaf.basic.BasicBorders that uses RadioButton.light and RadioButton.highlight:

    public static Border getRadioButtonBorder() {
    UIDefaults table = UIManager.getLookAndFeelDefaults();
    Border radioButtonBorder = new BorderUIResource.CompoundBorderUIResource(
               new BasicBorders.RadioButtonBorder(
                       table.getColor("RadioButton.shadow"),
                                           table.getColor("RadioButton.darkShadow"),
                                           table.getColor("RadioButton.light"),
                                           table.getColor("RadioButton.highlight")),
                         new MarginBorder());
    return radioButtonBorder;
    }
    

    However, it is may not be used by concrete L&F implementations.

    PS: UIManager Defaults by @camickr can be handy to visualize different keys.