RFR: 8150564: Migrate useful ExtendedRobot methods into awt.Robot [v4]
Chen Liang
liach at openjdk.org
Fri Sep 5 18:55:11 UTC 2025
On Fri, 5 Sep 2025 17:15:47 GMT, Phil Race <prr at openjdk.org> wrote:
>> src/java.desktop/share/classes/java/awt/Robot.java line 977:
>>
>>> 975: public synchronized void type(int keycode) {
>>> 976: keyPress(keycode);
>>> 977: waitForIdle(20);
>>
>> Should this use `DEFAULT_STEP_DELAY` too?
>
> In the code this is based on (ExtendedRobot.java) it was called DEFAULT_SPEED and used by click and type as well as glide
> As 'named' now, DEFAULT_STEP_DELAY is only appropriate for glide(..). There's no "stepping" here.
>
> And yet click(..) uses it (internally)
>
> so long as we don't document the name DEFAULT_STEP_DELAY on click() or type() it isn't critical.
> I see a number of choices
> - Use literal 20 here and in click
> - Use DEFAULT_STEP_DELAY here and in click - do not document
> - Add a new (private) DEFAULT_DELAY - and use it in both cases
> - Add a new public DEFAULT_DELAY - and use it in both cases and document it
> - Rename DEFAULT_STEP_DELAY to DEFAULT_DELAY - and use it in click and type as well as glide
>
> I'm inclined to go with the last of these - CSR will need to be revised.
> But if we don't do that one now, it will be awkward to do later.
> Thoughts ?
>
> PS I can see the potential need for an overload of click() and type() which accepts an alternate delay but I don't propose it here, I just note that for click() it would not be possible for the default click() to just accept a delay since that would clash with click(int buttons).
I recommend revising the CSR. Since the CSR already has reviewers, once it is updated, it can be directly finalized for re-approval. Just describe the changes in a comment, and it should proceed smoothly.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26969#discussion_r2325818064
More information about the client-libs-dev
mailing list