On Tue, 4 Nov 2025 13:46:22 GMT, Alexey Ivanov <[email protected]> wrote:

>> I would even format it like this, wrapping all the chained calls:
>> 
>> 
>>     public static Component findSubComponent(Component parent, String 
>> className) {
>>         return findComponentImpl((Container) parent,
>>                                  c -> c.getClass()
>>                                        .getName()
>>                                        .contains(className));
>>     }
>
> I also suggest calling `findComponent` instead of `findComponentImpl` — then 
> you can remove the line *“Always run this method on the EDT thread”* from the 
> javadoc comment.
> 
> Also, change “a sub component” to “a subcomponent”.

> It fails because the code I proposed is plainly wrong.
> 
> ```java
>     public static Component findSubComponent(Component parent, String 
> className) {
>         return findComponentImpl((Container) parent,
>                                  c -> 
> c.getClass().getName().contains(className));
>     }
> ```

This time I tested the above code by running the following tests 
`test/jdk/javax/swing/JFileChooser/FileChooserToolTipTest.java 
test/jdk/javax/swing/JFileChooser/FCPopupMenuOrientationTest.java` which use 
`Util.findSubComponent` and the tests passed for me.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27944#discussion_r2490642394

Reply via email to