【问题标题】:what do these swing color names mean这些摇摆颜色名称是什么意思
【发布时间】:2013-03-03 01:26:13
【问题描述】:

有些名称很清楚,例如背景、前景、焦点等。但有些名称只是令人困惑,例如 light、hightlight、shadow、darkshardow 等。我注意到这些在 Swing UI 中一直使用,所以我推断这些是java术语的一部分。有没有人知道那里是否有解释这些名称的文件?

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

【问题讨论】:

  • 为什么不单独将它们更改为粉红色,看看会发生什么?
  • 我已经尝试了好几个星期了,似乎没有受到任何影响,尤其是光线,突出显示:(

标签: java swing jradiobutton uimanager


【解决方案1】:

这些是与JRadionButton 相关的UIResource 元素。每个Look & Feel 提供不同的单选按钮外观,并且可以为这些元素设置不同的默认值。是否使用这些键也取决于 L&F 实现。

例如,这是来自javax.swing.plaf.basic.BasicBorders 的一个使用RadioButton.lightRadioButton.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;
}

但是,具体的 L&F 实现可能不会使用它。

PS: @camickr 的UIManager Defaults 可以方便地可视化不同的键。

【讨论】:

    猜你喜欢
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    • 2013-05-09
    • 1970-01-01
    • 2013-08-20
    • 2014-12-24
    • 2020-09-25
    • 1970-01-01
    相关资源
    最近更新 更多