RFR: JDK-8353755 : Add a helper method to Util - findComponent() [v5]
Alexey Ivanov
aivanov at openjdk.org
Wed Nov 5 18:42:15 UTC 2025
On Wed, 5 Nov 2025 17:58:05 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:
>> `findComponent(final Container container, final Predicate<Component> predicate)` is a useful utility method and thus added to` javax/swing/regtesthelpers/Util.java` instead of having redundant code in tests. It can be used to find a component by label name.
>>
>> PS: Existing `Util.findSubComponent()` finds component by class name but `findComponent()` can be used to search for a particular component by label name/title when there are multiple subcomponents of same type by applying a predicate logic.
>
> Harshitha Onkar has updated the pull request incrementally with one additional commit since the last revision:
>
> indentation
Changes requested by aivanov (Reviewer).
test/jdk/javax/swing/regtesthelpers/Util.java line 147:
> 145: */
> 146: public static Component findSubComponent(Component parent, String className) {
> 147: return findComponentImpl((Container) parent,
To guarantee, it's run on EDT, you have to call `findComponent`.
test/jdk/javax/swing/regtesthelpers/Util.java line 324:
> 322: Box buttonBox = Box.createHorizontalBox();
> 323: JButton passButton = new JButton("Pass");
> 324: JButton failButton = new JButton("Fail");
I'd leave these lines untouched.
Usages of `createModalDialogWithPassFailButtons` could be replaced with `PassFailJFrame` for consistency. It's out of scope.
-------------
PR Review: https://git.openjdk.org/jdk/pull/27944#pullrequestreview-3423742869
PR Review Comment: https://git.openjdk.org/jdk/pull/27944#discussion_r2495689923
PR Review Comment: https://git.openjdk.org/jdk/pull/27944#discussion_r2495697707
More information about the client-libs-dev
mailing list