Skip to content

Conversation

@honkar-jdk
Copy link
Contributor

@honkar-jdk honkar-jdk commented Oct 22, 2025

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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8353755: Add a helper method to Util - findComponent() (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27944/head:pull/27944
$ git checkout pull/27944

Update a local copy of the PR:
$ git checkout pull/27944
$ git pull https://git.openjdk.org/jdk.git pull/27944/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27944

View PR using the GUI difftool:
$ git pr show -t 27944

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27944.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 22, 2025

👋 Welcome back honkar! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 22, 2025

@honkar-jdk This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8353755: Add a helper method to Util - findComponent()

Reviewed-by: aivanov, tr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 302 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Oct 22, 2025
@openjdk
Copy link

openjdk bot commented Oct 22, 2025

@honkar-jdk The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 22, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 22, 2025

@prrace
Copy link
Contributor

prrace commented Nov 2, 2025

@TejeshR13 please review

Copy link
Contributor Author

@honkar-jdk honkar-jdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aivanov-jdk
Updated. Please re-review.

Copy link
Contributor

@TejeshR13 TejeshR13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for updating the test files with this PR ? I feel this PR should be restricted to Util file updates alone, updating the test files can be taken up separately.

robot.mouseMove(dlgBtnLoc.x , dlgBtnLoc.y);
robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
robot.delay(500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the clicks above are to click a button… Should we replace these clicks with programmatic clicks?

However, I'd like to ensure the updated test still reproduces the original bug. Updating this test could better pull out into its own issue. (Yes, I remember that this refactoring comes from an internal comment I made when javax/swing/JFileChooser/bug4759934.java was open-sourced.)

Copy link
Contributor Author

@honkar-jdk honkar-jdk Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be updating the tests in another PR.

To answer your question.

All the clicks above are to click a button… Should we replace these clicks with programmatic clicks?

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 we keep much of the original test case intact without overly modifying it.

Comment on lines 232 to 234
Component result = Util.findComponent(container,
c -> c instanceof JToggleButton button
&& "Details".equals(button.getToolTipText()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Component result = Util.findComponent(container,
c -> c instanceof JToggleButton button
&& "Details".equals(button.getToolTipText()));
Component result = Util.findComponent(container,
c -> c instanceof JToggleButton button
&& "Details".equals(button.getToolTipText()));

Let's not touch the indentation of the second parameter. The comment below is marked as resolved but it's not resolved. This is what I meant.

That is, only Util. is added, only one line of the findDetailsButton method changes compared to master.

@aivanov-jdk
Copy link
Member

aivanov-jdk commented Nov 4, 2025

Any reason for updating the test files with this PR ? I feel this PR should be restricted to Util file updates alone, updating the test files can be taken up separately.

This is a valid concern. I tend to agree. The test from which the findComponent method is moved to the Util class, javax/swing/JFileChooser/FileSizeCheck.java, isn't backported to any releases. Yet I expect this change to Util would be backported to all the supported releases.

This is why I suggest submitting a new bug to update FileSizeCheck.java. (That new bug would be backported to 21u where the test FileSizeCheck.java exists.)

Similarly, as I just mentioned, it makes sense to update javax/swing/JFileChooser/bug4759934.java in its own issue to keep the history clearer. Especially, if we replace all button clicks with programmatic doClick instead of using robot.

@honkar-jdk
Copy link
Contributor Author

@aivanov-jdk As suggested I'll be creating separate PRs for test changes.

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, except for minor formatting nit.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 6, 2025
Copy link
Contributor

@TejeshR13 TejeshR13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 6, 2025
@honkar-jdk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 7, 2025

Going to push as commit 3549103.
Since your change was applied there have been 326 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 7, 2025
@openjdk openjdk bot closed this Nov 7, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 7, 2025
@openjdk
Copy link

openjdk bot commented Nov 7, 2025

@honkar-jdk Pushed as commit 3549103.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client client-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants