[jdk20] RFR: 8301989: new javax.swing.text.DefaultCaret().setBlinkRate(N) results in NPE [v2]

Phil Race prr at openjdk.org
Wed Feb 8 17:05:50 UTC 2023


On Tue, 7 Feb 2023 23:16:14 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java line 1054:
>> 
>>> 1052:         if (rate != 0) {
>>> 1053:             if (component != null && component.isEditable()) {
>>> 1054:                 if (flasher == null) {
>> 
>> So later if there is a non-editable component, what happens ?
>> Some existing logic for that will kick in ?
>
> Yes, when the the caret is to be assigned to a component it will reset the blink rate and the logic will kick in. Manually tested with the possible scenarios like adding custom set blink rate cursor to a non-editable component and then turn it into editable later, add to editable and switch to non-editable later and so on.

So if I go back and look at the code before your previous fix, there was no check,
so the timer is created and then I'd expect applies when the caret is installed on a component.
Here that behaviour is changed, so that if we create a caret, then call setBlinkRate(), and then install()
then the blink rate appears to be ignored whereas before 4512626 it was applied.

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

PR: https://git.openjdk.org/jdk20/pull/122



More information about the client-libs-dev mailing list