RFR: 7188058: Background of TextComponents are not changing colors to the default disabled color when set to uneditable [v5]
Abhishek Kumar
abhiscxk at openjdk.org
Fri Aug 23 05:28:12 UTC 2024
On Tue, 20 Aug 2024 23:53:45 GMT, Alisen Chung <achung at openjdk.org> wrote:
>> Currently the bug described in the issue is that the colors of the TextComponents do not change when setting TextComponents to uneditable. The default uneditable color (SystemColor.control) happens to be the same as the default for the editable color for some L&Fs, so the fix may not be initially noticeable. However, the bug still exists where the the color is not being changed when changing between editable and uneditable. You can check by changing TextComponent.getBackground() code to return Color.GRAY on line 342 and you can see that TextComponents are not changing to a gray background when set to uneditable.
>>
>> This fix adds a private setBackground method in TextComponent so that TextArea and TextField can change the background color to the correct color (SystemColor.control) when set uneditable by overriding the TextComponent setEditable. You can verify the fix by changing this color to Color.GRAY and verifying the backgrounds change to gray when the TextComponents are disabled.
>
> Alisen Chung has updated the pull request incrementally with one additional commit since the last revision:
>
> fix import
src/java.desktop/share/classes/java/awt/TextArea.java line 610:
> 608:
> 609: @Override
> 610: public synchronized void setEditable(boolean b) {
`setEditable` method is overridden in both `TextArea` and `TextField` class and method implementation is same. Since both of them are inherited from `TextComponent` class, could we move the code to `TextComponent's setEditable` method and remove them from respective classes?
test/jdk/java/awt/TextComponent/BackgroundTest.java line 1:
> 1: /*
@ Ran the test on mac machine and I observed no changes with or without your fix. And the text on first textfield seems selected and due to that it is of different color. Is it possible to make them unselected at test start up, so that the background color can be verified for enabled and disabled case easily?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19876#discussion_r1728380686
PR Review Comment: https://git.openjdk.org/jdk/pull/19876#discussion_r1728381311
More information about the client-libs-dev
mailing list