RFR: 8150564: Migrate useful ExtendedRobot methods into awt.Robot [v4]
Phil Race
prr at openjdk.org
Fri Sep 5 17:18:16 UTC 2025
On Thu, 4 Sep 2025 00:13:15 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Damon Nguyen has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add finally block
>
> 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).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26969#discussion_r2325646757
More information about the client-libs-dev
mailing list