On Wed, 18 Sep 2024 12:05:22 GMT, Alexey Ivanov <[email protected]> wrote:

> 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?

This pull request has now been integrated.

Changeset: e97f0fe1
Author:    Alexey Ivanov <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/e97f0fe1b4046bfcc40e85ba1bee4f4c40053300
Stats:     3 lines in 1 file changed: 0 ins; 2 del; 1 mod

8340365: Position the first window of a window list

Reviewed-by: azvegint, prr

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

PR: https://git.openjdk.org/jdk/pull/21057

Reply via email to