RFR: JDK-8371365 : Update /javax/swing/JFileChooser/bug4759934.java to use Util.findComponent()
Alexey Ivanov
aivanov at openjdk.org
Thu Nov 6 13:29:05 UTC 2025
On Thu, 6 Nov 2025 13:12:13 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> /javax/swing/JFileChooser/bug4759934.java test changes related to addition of new method to Util - https://github.com/openjdk/jdk/pull/27944.
>
> test/jdk/javax/swing/JFileChooser/bug4759934.java line 74:
>
>> 72: robot.mouseMove(dlgBtnLoc.x , dlgBtnLoc.y);
>> 73: robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
>> 74: robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
>
> https://github.com/openjdk/jdk/pull/27944#discussion_r2490547507
>
>> All the clicks above are to click a button… Should we replace these clicks with programmatic clicks?
>
> This is more reliable and quicker than robot.
>
> The only possible issue is to to ensure the updated test still reproduces the original bug.
I just noticed your comment: https://github.com/openjdk/jdk/pull/27944#discussion_r2496343433
> I'm for keeping the other clicks as-is (via Robot) since we have reference to these buttons unlike the cancel button of JFileChooser and this way keep much of the original test case intact without overly modifying it.
“…Since we have reference to these buttons,” it's even easier to call `frameBtn.doClick()` and `dlgBtnLoc.doClick()`.
Once you get the reference to the Cancel button in the file chooser you can also use robot to click the button.
Using consistently the same method to click the buttons makes the test easier to comprehend.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28169#discussion_r2498964348
More information about the client-libs-dev
mailing list