On Wed, 3 Jul 2024 05:20:02 GMT, Harshitha Onkar <[email protected]> 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.
>
> src/java.desktop/share/classes/java/awt/TextArea.java line 615:
>
>> 613: Color defaultBackground =
>> UIManager.getColor("TextArea.background");
>> 614: if (!backgroundSetByClientCode) {
>> 615: setBackground(b ? defaultBackground : SystemColor.control,
>> false);
>
> Is there a reason behind choosing `SystemColor.control` as the default
> TextComponent system color?
> I see another option `SystemColor.text` - the description sounds more close
> to the background color of text components.
the SystemColor.control comes from the docs on TextComponent.setEditable
* If the flag is set to {@code true}, this text component
* becomes user editable. If the flag is set to {@code false},
* the user cannot change the text of this text component.
* By default, non-editable text components have a background color
* of SystemColor.control. This default can be overridden by
* calling setBackground.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19876#discussion_r1664909788