On Wed, 6 Mar 2024 08:57:07 GMT, Abhishek Kumar <abhis...@openjdk.org> wrote:

>> Backtracking a bit, regarding `Label.foreground` why it needs to be done 
>> here?
>> 
>> Other L&F, it is added in corresponding LookAndFeel class
>> for example, in 
>> [Metal](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java#L1001)
>> and in 
>> [Windows](https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java#L880)
>> etc
>> so I think it is needed to be added in GTKLookAndFeel class
>> 
>> and additionally there is setting of `Label.foreground` and other Label. 
>> property in BasicLabelUI.java 
>> [installDefaults](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java#L368)
>> but we dont do it for Nimbus or GTK or Synth so I guess we need to call 
>> `super.installDefaults(c)` in SynthLabelUI class since there is no 
>> GTKLabelUI class
>> or 
>> maybe do
>> `LookAndFeel.installColorsAndFont(c, "Label.background", "Label.foreground", 
>> "Label.font");` alone to avoid other properties being set and to not fallback
>> 
>> Please check if it will work
>> and if it does, then we need to employ similar for 
>> checbox/radiobutton/togglebutton
>
> I will check and update.

> Backtracking a bit, regarding `Label.foreground` why it needs to be done here?
> 
> Other L&F, it is added in corresponding LookAndFeel class for example, in 
> [Metal](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java#L1001)
>  and in 
> [Windows](https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java#L880)
>  etc so I think it is needed to be added in GTKLookAndFeel class

IN GTKLookAndFeel, the color is returned specific to the style and state from 
native side . So, even if it is not added the default color for enabled, 
disabled or any other state is returned by native. Whereas In Metal the color 
is set by using UIManager define color.

> and additionally there is setting of Label.foreground and other Label. 
> property in BasicLabelUI.java 
> [installDefaults](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java#L368)
but we dont do it for Nimbus or GTK or Synth so I guess we need to call 
super.installDefaults(c) in SynthLabelUI class since there is no GTKLabelUI 
class
or
maybe do
LookAndFeel.installColorsAndFont(c, "Label.background", "Label.foreground", 
"Label.font"); alone to avoid other properties being set and to not fallback

This properties are set via SynthStyle `installDefaults` method where the 
foreground, background are set by getting the value from `getColorForState` 
method. So, calling super.installDefaults(c) in SynthLabelUI will not make any 
difference.

I checked for JLabel properties set in enabled and disabled state. 


In Nimbus LAF
            UIManager.getDefaults().put("Label[Enabled].textForeground", 
labelColor);
            UIManager.getDefaults().put("Label[Disabled].textForeground", 
labelDisabledColor);

Other LAF
            UIManager.getDefaults().put("Label.foreground", labelColor);
            UIManager.getDefaults().put("Label.disabledForeground", 
labelDisabledColor);


It works as expected for Metal and GTK. For Nimbus LAF, disabled color is not 
painted correctly. In stead the default color specified in skin.laf is rendered.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17763#discussion_r1515994970

Reply via email to