On Mon, 14 Aug 2023 21:00:56 GMT, Alisen Chung <ach...@openjdk.org> wrote:
>> @alisenchung >> >> An automated test can be created by adding Component Listener to the >> reproducer test in JBS. The following code throws Runtime Exception if the >> frame was visible at the original size of 200 x 200 before it was maximized. >> >> >> frame.addComponentListener(new ComponentAdapter() { >> @Override >> public void componentResized(ComponentEvent e) { >> if (e.getComponent().getSize().equals(new Dimension(200, 200))) { >> throw new RuntimeException("Test Failed! " + >> "Original Frame size was visible before maximizing"); >> } >> } >> }); > >> @alisenchung >> >> An automated test can be created by adding Component Listener to the >> reproducer test in JBS. The following code throws Runtime Exception if the >> frame was visible at the original size of 200 x 200 before it was maximized. >> >> ``` >> frame.addComponentListener(new ComponentAdapter() { >> @Override >> public void componentResized(ComponentEvent e) { >> if (e.getComponent().getSize().equals(new Dimension(200, 200))) { >> throw new RuntimeException("Test Failed! " + >> "Original Frame size was visible before maximizing"); >> } >> } >> }); >> ``` > > When I run the test manually after the change I'm not able to see a small > window anymore. Won't this code always fail since you listen for a resize > event then check the size of the window right before the window is resized? @alisenchung I think another option would be to override `componentShown()` of ComponentListener and check the size of the frame returned when it is made visible. With original code, I think it would show 200x200 and with the fix , the maximized frame size. I haven't tested this option though. @Override public void componentShown(ComponentEvent e) { System.out.println(e.getComponent().getSize()); } ------------- PR Comment: https://git.openjdk.org/jdk/pull/15236#issuecomment-1678195782