On Wed, 22 Apr 2026 19:14:48 GMT, Alexey Ivanov <[email protected]> wrote:
>> Alexander Zuev has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Add null check for caret and background color reported by the component.
>
> src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java line 703:
>
>> 701: Color bg = component.getBackground();
>> 702: if (bg == null) {
>> 703: g.setColor(caretColor);
>
> Does it make sense to add alpha to the caret if background color is null?
This is a fallback which in theory should never happen because according to
documentation it is impossible to set caret color to null, documentation for
`setCaretColor` says:
[Setting to null effectively restores the default
color.](https://docs.oracle.com/en/java/javase/26/docs/api/java.desktop/javax/swing/text/JTextComponent.html#setCaretColor(java.awt.Color))
so i would leave it as is and instead looked at the Nimbus LaF to see why does
it return null caret color for the disabled caret. Using the foreground color
is a workaround to repeat the current behavior, not a proper solution. It might
backfire on custom text component where user paints with some weird color
something between text draw and caret painting.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30758#discussion_r3128127772