Support of multiple test UI windows in `PassFailJFrame` is still evolving. After [JDK-8340210](https://bugs.openjdk.org/browse/JDK-8340210), the `Builder` has a method `positionTestUI` to supply an implementation of the `PositionWindows` interface which handles the positioning of all test UI windows created.
If `PositionWindows` is not provided, all the test UI windows are left with the default coordinates: (0, 0). If `PassFailJFrame` called `positionTestWindow` for the first window, it would allow the test developer to position other windows based on the position of the first one. This issue was raised in #21029 in [this thread of comments](https://github.com/openjdk/jdk/pull/21029#discussion_r1763744407). To make it easier to position multiple test UI windows without implementing the `PositionWindows` interface, the `PassFailJFrame` should position the first window of the list. The `LotsOfMenuItemsTest.java` test in #21029 had to hard-code the coordinates or use `PassFailJFrame.positionTestWindow` explicitly in its `ComponentListener.componentShown`. With the proposed change in this pull request, the implementation would use `ComponentListener.componentMoved`: @Override public void componentMoved(ComponentEvent e) { testFrame.setLocation(firstFrame.getX(), firstFrame.getY() + firstFrame.getHeight() + 8); } This has the advantage in that the test UI windows don't flicker for a short time in the upper left corner of the screen; and the developer has to handle only positioning the second window (frame). However, this has a funny effect: if you move the first frame with mouse or in any other way, the second frame follows. To avoid such kind of behaviour, call `removeComponentListener` in the handler. @honkar-jdk, @azvegint, could you take a look? ------------- Commit messages: - 8340365: Position the first window of a window list Changes: https://git.openjdk.org/jdk/pull/21057/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21057&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8340365 Stats: 3 lines in 1 file changed: 0 ins; 2 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/21057.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21057/head:pull/21057 PR: https://git.openjdk.org/jdk/pull/21057
