RFR: 7188058: Background of TextComponents are not changing colors to the default disabled color when set to uneditable [v2]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Tue Aug 6 09:28:34 UTC 2024
On Mon, 5 Aug 2024 16:59:50 GMT, Alisen Chung <achung at openjdk.org> wrote:
>> src/java.desktop/share/classes/java/awt/TextArea.java line 613:
>>
>>> 611: public synchronized void setEditable(boolean b) {
>>> 612: super.setEditable(b);
>>> 613: Color defaultBackground = UIManager.getColor("TextArea.background");
>>
>> I am not sure if it is ok to use swing "UIManager" class in awt
>> I guess long time back somebody maybe @prrace mentioned that we should avoid calling swing class from awt?
>> I see we use AttributeSet in TextComponent for accessibility usage but am not sure if we can use without restriction?
>
> This call is only to get the default background of TextArea. Is there another way to grab the default color without using UIManager?
Yes, but as far I could see `TextArea.background` property is being set in
`AquaLookAndFeel.java, MotifLookAndFeel.java, BasicLookAndFeel.java, XAWTLookAndFeel.java and WindowsLookAndFeel.java`
and this L&F will not be set in AWT environment, if I am not wrong so you will either get garbage or wrong default color if you use UIManager.getColor..so I guess you need to use `TextComponent.getBackground()` which returns SystemColor.control if nothing is set
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19876#discussion_r1705216392
More information about the client-libs-dev
mailing list