diff --git a/test/jdk/java/awt/Frame/FrameRepackTest.java b/test/jdk/java/awt/Frame/FrameRepackTest.java index e167d846317ae..52a3fcf269bdc 100644 --- a/test/jdk/java/awt/Frame/FrameRepackTest.java +++ b/test/jdk/java/awt/Frame/FrameRepackTest.java @@ -50,7 +50,7 @@ public class FrameRepackTest { The menubar has one menu, labelled 'Flip'. The menu has two items, labelled 'visible' and 'not visible'. The frame also contains a red panel that contains two line labels, - ' This panel is always displayed' and ' it is a test'. + 'This panel is always displayed' and 'it is a test'. If you select the menu item 'Flip->visible', then another panel is added below the red panel. @@ -61,7 +61,7 @@ public class FrameRepackTest { You can repeatedly add and remove the second panel in this way. After such an addition or removal, the frame's location on the screen - should not have changed, while the size changes to accommodate + should not change, while the size changes to accommodate either just the red panel or both the red and the blue panels. If you resize the frame larger, the red panel remains at the @@ -113,7 +113,6 @@ public FrameRepack() { // create the options Menu flip = new Menu("Flip"); MenuItem mi; - flip.addSeparator(); mi = new MenuItem("visible"); mi.addActionListener(this); flip.add(mi); @@ -130,8 +129,8 @@ public FrameRepack() { Panel north = new Panel(); north.setBackground(Color.red); north.setLayout(new BorderLayout(2, 2)); - north.add("North", new Label(" This panel is always displayed")); - north.add("Center", new Label(" it is a test ")); + north.add("North", new Label("This panel is always displayed")); + north.add("Center", new Label("it is a test")); north.setSize(200, 200); add("North", north); @@ -161,16 +160,15 @@ public FrameRepack() { pack(); } + @Override public void actionPerformed(ActionEvent evt) { if (evt.getSource() instanceof MenuItem) { if (evt.getActionCommand().equals("visible")) { south.setVisible(true); pack(); - setVisible(true); } else if (evt.getActionCommand().equals("not visible")) { south.setVisible(false); pack(); - setVisible(true); } } } diff --git a/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_1.java b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_1.java index 9863c951653eb..0352bf5927534 100644 --- a/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_1.java +++ b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_1.java @@ -42,10 +42,12 @@ public class FrameResizeTest_1 { private static final String INSTRUCTIONS = """ To the right of this frame is an all-white 200x200 frame. - This is actually a white canvas component of the frame. + This is actually a white canvas component in the frame. The frame itself is red. The red should never show. In particular, after you resize the frame, you should see all white and no red. + (During very fast window resizing, red color may appear briefly, + which is not a failure.) Upon test completion, click Pass or Fail appropriately. """; @@ -55,7 +57,7 @@ public static void main(String[] args) throws Exception { .title("FrameResizeTest_1 Instructions") .instructions(INSTRUCTIONS) .testTimeOut(5) - .rows(9) + .rows(12) .columns(45) .build(); diff --git a/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_2.java b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_2.java index 0f7e7a97a9140..bbcd8d5011514 100644 --- a/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_2.java +++ b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_2.java @@ -84,20 +84,20 @@ class FrameResize_2 extends Frame { FrameResize_2() { super("FrameResize_2"); - setLayout( new GridBagLayout() ); + setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; - Container dumbc = new DumbC(); - add( dumbc, c ); + Container dumbContainer = new DumbContainer(); + add(dumbContainer, c); - Panel dump = new DumbPanel(); - add( dump, c ); + Panel dumbPanel = new DumbPanel(); + add(dumbPanel, c); - setSize( new Dimension( 300, 300)); + setSize(300, 300); } } @@ -115,8 +115,8 @@ public void paint(Graphics g) { } } -class DumbC extends Container { - public DumbC() { +class DumbContainer extends Container { + public DumbContainer() { setLayout(new BorderLayout()); add("Center", new Fake("dumbc", Color.red)); } diff --git a/test/jdk/java/awt/Frame/WindowMoveTest.java b/test/jdk/java/awt/Frame/WindowMoveTest.java index 59daf6cc75c40..66049e63c6ad0 100644 --- a/test/jdk/java/awt/Frame/WindowMoveTest.java +++ b/test/jdk/java/awt/Frame/WindowMoveTest.java @@ -29,6 +29,7 @@ import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /* * @test @@ -53,7 +54,9 @@ public static void main(String[] args) throws Exception { EventQueue.invokeAndWait(() -> frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING))); - WindowMove.latch.await(); + if (!WindowMove.latch.await(10, TimeUnit.SECONDS)) { + throw new RuntimeException("Test timeout."); + } if (WindowMove.failMessage != null) { throw new RuntimeException(WindowMove.failMessage); @@ -66,7 +69,7 @@ class WindowMove extends Frame implements WindowListener { new Rectangle(100, 100, 300, 300); static CountDownLatch latch = new CountDownLatch(1); - static volatile String failMessage = null; + static String failMessage = null; private boolean layoutCheck; private boolean visibleCheck; @@ -92,7 +95,7 @@ public WindowMove() { if (checkBounds()) { visibleCheck = true; } - System.out.println("setVisible bounds: " + getBounds()); + System.out.println("setVisible bounds: " + getBounds()); } private boolean checkBounds() { @@ -105,7 +108,7 @@ public void checkResult() { && openedCheck && closingCheck && closedCheck) { - System.out.println("Test passed"); + System.out.println("Test passed."); } else { failMessage = """ Some of the checks failed: