1

background、foreground、focus などのように明確な名前もあります。しかし、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          
4

1 に答える 1

5

これらはにUIResource関連する要素JRadionButtonです。それぞれ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のデフォルトは、さまざまなキーを視覚化するのに便利です。

于 2013-03-03T03:17:26.180 に答える