diff --git a/test/jdk/java/awt/Dialog/ModalDialogTest/ModalDialogTest.java b/test/jdk/java/awt/Dialog/ModalDialogTest/ModalDialogTest.java
index ee125f0fd1c..610b122e7f9 100644
--- a/test/jdk/java/awt/Dialog/ModalDialogTest/ModalDialogTest.java
+++ b/test/jdk/java/awt/Dialog/ModalDialogTest/ModalDialogTest.java
@@ -47,6 +47,7 @@ import java.awt.event.MouseMotionListener;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
 import java.lang.reflect.InvocationTargetException;
+import javax.swing.SwingUtilities;
 
 /*
  * @test
@@ -210,7 +211,9 @@ class WindowPanel extends Panel {
         win.add(center, BorderLayout.CENTER);
         win.add(bottom, BorderLayout.SOUTH);
         win.pack();
-        win.setVisible(true);
+        if (windows != 0) {
+            win.setVisible(true);
+        }
 
         PassFailJFrame.addTestWindow(win);
     }
@@ -344,16 +347,20 @@ public class ModalDialogTest {
         PassFailJFrame passFailJFrame = new PassFailJFrame("ModalDialogTest " +
         "Instructions", getInstructions(), 10, 20, 60);
 
-        WindowPanel.buildAndShowWindow(
-            frame,
-            new Label("Owner: none"),
-            new TestPanel(new TextArea(10, 30)),
-            new WindowPanel()
-        );
+        SwingUtilities.invokeAndWait(() ->{
+            WindowPanel.buildAndShowWindow(
+                frame,
+                new Label("Owner: none"),
+                new TestPanel(new TextArea(10, 30)),
+                new WindowPanel()
+            );
+
+            // adding only the root frame to be positioned
+            // w.r.t instruction frame
+            passFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
+            frame.setVisible(true);
+        });
 
-        // adding only the root frame to be positioned
-        // w.r.t instruction frame
-        passFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
         passFailJFrame.awaitAndCheck();
     }
 }
diff --git a/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java b/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java
index 962950a7b79..ed72ce115cf 100644
--- a/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java
+++ b/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java
@@ -81,6 +81,10 @@ public class TrayIconScalingTest {
         PassFailJFrame passFailJFrame = new PassFailJFrame("TrayIcon " +
                 "Test Instructions", INSTRUCTIONS, 8, 18, 85);
         createAndShowGUI();
+        // does not have a test window,
+        // hence only the instruction frame is positioned
+        PassFailJFrame.positionTestWindow(null,
+                PassFailJFrame.Position.HORIZONTAL);
         try {
             passFailJFrame.awaitAndCheck();
         } finally {
diff --git a/test/jdk/java/awt/print/PrinterJob/ImagePrinting/ClippedImages.java b/test/jdk/java/awt/print/PrinterJob/ImagePrinting/ClippedImages.java
index daaeeb33dc4..5ef6f7a8458 100644
--- a/test/jdk/java/awt/print/PrinterJob/ImagePrinting/ClippedImages.java
+++ b/test/jdk/java/awt/print/PrinterJob/ImagePrinting/ClippedImages.java
@@ -59,6 +59,7 @@ import static java.awt.EventQueue.invokeAndWait;
 public class ClippedImages {
 
     private static ClippedImageCanvas c;
+    private static Frame frame;
 
     public static void main(String[] args) throws InterruptedException,
             InvocationTargetException {
@@ -100,7 +101,7 @@ public class ClippedImages {
     }
 
     public static void createTestUI() {
-        Frame frame = new Frame("Clipped Src Area Image Printing Test");
+        frame = new Frame("Clipped Src Area Image Printing Test");
         c = new ClippedImageCanvas();
         frame.add(c, BorderLayout.CENTER);
 
@@ -123,10 +124,10 @@ public class ClippedImages {
         frame.add(p, BorderLayout.SOUTH);
         frame.setLocationRelativeTo(null);
         frame.pack();
-        frame.setVisible(true);
 
         PassFailJFrame.addTestWindow(frame);
         PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
+        frame.setVisible(true);
     }
 
     private static void printOne() {
diff --git a/test/jdk/java/awt/print/PrinterJob/PrintGlyphVectorTest.java b/test/jdk/java/awt/print/PrinterJob/PrintGlyphVectorTest.java
index 72115670fef..bd921b5162d 100644
--- a/test/jdk/java/awt/print/PrinterJob/PrintGlyphVectorTest.java
+++ b/test/jdk/java/awt/print/PrinterJob/PrintGlyphVectorTest.java
@@ -34,13 +34,11 @@ import java.awt.BorderLayout;
 import java.awt.Button;
 import java.awt.Color;
 import java.awt.Component;
-import java.awt.Dialog;
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Frame;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
-import java.awt.Label;
 import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
 import java.awt.geom.Point2D;
@@ -51,6 +49,7 @@ import java.awt.print.PrinterException;
 import java.awt.print.PrinterJob;
 
 public class PrintGlyphVectorTest extends Component implements Printable {
+    private static Frame f;
 
     private static final String INSTRUCTIONS = """
             Note: You must have a printer installed for this test.
@@ -128,7 +127,7 @@ public class PrintGlyphVectorTest extends Component implements Printable {
             PassFailJFrame.forcePass();
         }
 
-        Frame f = new Frame("Test PrintGlyphVector");
+        f = new Frame("Test PrintGlyphVector");
         PrintGlyphVectorTest pvt = new PrintGlyphVectorTest();
         f.add(pvt, BorderLayout.CENTER);
 
@@ -149,13 +148,13 @@ public class PrintGlyphVectorTest extends Component implements Printable {
 
         f.add(printButton, BorderLayout.SOUTH);
         f.pack();
-        f.setVisible(true);
 
         // add the test frame to dispose
         PassFailJFrame.addTestWindow(f);
 
         // Arrange the test instruction frame and test frame side by side
         PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
+        f.setVisible(true);
     }
 
     public static void main(String[] arg) throws Exception {
diff --git a/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java b/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java
index b2e076ec463..785855749a8 100644
--- a/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java
+++ b/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java
@@ -74,8 +74,6 @@ public class PrintLatinCJKTest implements Printable {
             });
             frame.getContentPane().add(b, BorderLayout.SOUTH);
             frame.pack();
-            frame.setLocationRelativeTo(null);
-            frame.setVisible(true);
 
             // add the test frame to dispose
             PassFailJFrame.addTestWindow(frame);
@@ -83,6 +81,7 @@ public class PrintLatinCJKTest implements Printable {
             // Arrange the test instruction frame and test frame side by side
             PassFailJFrame.positionTestWindow(frame,
                     PassFailJFrame.Position.HORIZONTAL);
+            frame.setVisible(true);
         });
     }
 
@@ -100,7 +99,7 @@ public class PrintLatinCJKTest implements Printable {
 
     public static void main(String[] args) throws InterruptedException, InvocationTargetException {
         PassFailJFrame passFailJFrame = new PassFailJFrame("Test Instruction" +
-                "Frame", info, 10, 40, 5);
+                "Frame", info, 10, 10, 45);
         showFrame();
         passFailJFrame.awaitAndCheck();
     }
diff --git a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
index b2f6be246f8..3910c022dd8 100644
--- a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
+++ b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
@@ -23,6 +23,10 @@
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Insets;
+import java.awt.Rectangle;
 import java.awt.Toolkit;
 import java.awt.Window;
 import java.awt.event.WindowAdapter;
@@ -41,6 +45,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 import javax.swing.Timer;
 
+
 import static javax.swing.SwingUtilities.invokeAndWait;
 import static javax.swing.SwingUtilities.isEventDispatchThread;
 
@@ -60,7 +65,7 @@ public class PassFailJFrame {
     private static volatile String testFailedReason;
     private static JFrame frame;
 
-    public enum Position {HORIZONTAL, VERTICAL}
+    public enum Position {HORIZONTAL, VERTICAL, TOP_LEFT_CORNER}
 
     public PassFailJFrame(String instructions) throws InterruptedException,
             InvocationTargetException {
@@ -171,7 +176,6 @@ public class PassFailJFrame {
         frame.add(buttonsPanel, BorderLayout.SOUTH);
         frame.pack();
         frame.setLocationRelativeTo(null);
-        frame.setVisible(true);
         windowList.add(frame);
     }
 
@@ -257,31 +261,116 @@ public class PassFailJFrame {
     }
 
     /**
-     * Position the instruction frame with testWindow (testcase created
-     * window) by the specified position.
-     * Note: This method should be invoked from the method that creates
-     * testWindow.
+     * Approximately positions the instruction frame relative to the test
+     * window as specified by the {@code position} parameter. If {@code testWindow}
+     * is {@code null}, only the instruction frame is positioned according to
+     * {@code position} parameter.
+     * <p>This method should be called before making the test window visible
+     * to avoid flickering.</p>
      *
-     * @param testWindow test window that the test is created
-     * @param position  position can be either HORIZONTAL (both test
-     *                  instruction frame and test window as arranged
-     *                  side by side) or VERTICAL (both test instruction
-     *                  frame and test window as arranged up and down)
+     * @param testWindow test window that the test created.
+     *                   May be {@code null}.
+     *
+     * @param position  position must be one of:
+     *                  <ul>
+     *                  <li>{@code HORIZONTAL} - the test instruction frame is positioned
+     *                  such that its right edge aligns with screen's horizontal center
+     *                  and the test window (if not {@code null}) is placed to the right
+     *                  of the instruction frame.</li>
+     *
+     *                  <li>{@code VERTICAL} - the test instruction frame is positioned
+     *                  such that its bottom edge aligns with the screen's vertical center
+     *                  and the test window (if not {@code null}) is placed below the
+     *                  instruction frame.</li>
+     *
+     *                  <li>{@code TOP_LEFT_CORNER} - the test instruction frame is positioned
+     *                  such that its top left corner is at the top left corner of the screen
+     *                  and the test window (if not {@code null}) is placed to the right of
+     *                  the instruction frame.</li>
+     *                  </ul>
      */
     public static void positionTestWindow(Window testWindow, Position position) {
         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+
+        // Get the screen insets to position the frame by taking into
+        // account the location of taskbar/menubars on screen.
+        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
+                .getDefaultScreenDevice().getDefaultConfiguration();
+        Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
+
         if (position.equals(Position.HORIZONTAL)) {
             int newX = ((screenSize.width / 2) - frame.getWidth());
-            frame.setLocation(newX, frame.getY());
-
-            testWindow.setLocation((frame.getLocation().x + frame.getWidth() + 5), frame.getY());
+            frame.setLocation((newX + screenInsets.left),
+                    (frame.getY() + screenInsets.top));
+            syncLocationToWindowManager();
+            if (testWindow != null) {
+                testWindow.setLocation((frame.getX() + frame.getWidth() + 5),
+                        frame.getY());
+            }
         } else if (position.equals(Position.VERTICAL)) {
             int newY = ((screenSize.height / 2) - frame.getHeight());
-            frame.setLocation(frame.getX(), newY);
-
-            testWindow.setLocation(frame.getX(),
-                    (frame.getLocation().y + frame.getHeight() + 5));
+            frame.setLocation((frame.getX() + screenInsets.left),
+                    (newY + screenInsets.top));
+            syncLocationToWindowManager();
+            if (testWindow != null) {
+                testWindow.setLocation(frame.getX(),
+                        (frame.getY() + frame.getHeight() + 5));
+            }
+        } else if (position.equals(Position.TOP_LEFT_CORNER)) {
+            frame.setLocation(screenInsets.left, screenInsets.top);
+            syncLocationToWindowManager();
+            if (testWindow != null) {
+                testWindow.setLocation((frame.getX() + frame.getWidth() + 5),
+                        frame.getY());
+            }
         }
+        // make instruction frame visible after updating
+        // frame & window positions
+        frame.setVisible(true);
+    }
+
+    /**
+     * Ensures the frame location is updated by the window manager
+     * if it adjusts the frame location after {@code setLocation}.
+     *
+     * @see #positionTestWindow
+     */
+    private static void syncLocationToWindowManager() {
+        Toolkit.getDefaultToolkit().sync();
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Returns the current position and size of the test instruction frame.
+     * This method can be used in scenarios when custom positioning of
+     * multiple test windows w.r.t test instruction frame is necessary,
+     * at test-case level and the desired configuration is not available
+     * as a {@code Position} option.
+     *
+     * @return Rectangle bounds of test instruction frame
+     * @see #positionTestWindow
+     *
+     * @throws InterruptedException      exception thrown when thread is
+     *                                   interrupted
+     * @throws InvocationTargetException if an exception is thrown while
+     *                                   obtaining frame bounds on EDT
+     */
+    public static Rectangle getInstructionFrameBounds()
+            throws InterruptedException, InvocationTargetException {
+        final Rectangle[] bounds = {null};
+
+        if (isEventDispatchThread()) {
+            bounds[0] = frame != null ? frame.getBounds() : null;
+        } else {
+            invokeAndWait(() -> {
+                bounds[0] = frame != null ? frame.getBounds() : null;
+            });
+        }
+        return bounds[0];
     }
 
     /**
diff --git a/test/jdk/javax/swing/JRadioButton/bug4380543.java b/test/jdk/javax/swing/JRadioButton/bug4380543.java
index 54d39b32cd5..0125a42274e 100644
--- a/test/jdk/javax/swing/JRadioButton/bug4380543.java
+++ b/test/jdk/javax/swing/JRadioButton/bug4380543.java
@@ -20,15 +20,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-/* @test
- * @bug 4380543
- * @key headful
- * @library /java/awt/regtesthelpers
- * @build PassFailJFrame
- * @summary setMargin() does not work for AbstractButton
- * @run main/manual bug4380543
-*/
-
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.event.ActionEvent;
@@ -45,6 +36,14 @@ import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
 
+/* @test
+ * @bug 4380543
+ * @key headful
+ * @library /java/awt/regtesthelpers
+ * @build PassFailJFrame
+ * @summary setMargin() does not work for AbstractButton
+ * @run main/manual bug4380543
+ */
 public class bug4380543 {
     static TestFrame testObj;
     static String instructions
@@ -62,17 +61,16 @@ public class bug4380543 {
 
     public static void main(String[] args) throws Exception {
 
-        SwingUtilities.invokeAndWait(new Runnable() {
-            public void run() {
-                try {
-                    passFailJFrame = new PassFailJFrame(instructions);
-                    testObj = new TestFrame();
-                    //Adding the Test Frame to handle dispose
-                    PassFailJFrame.addTestWindow(testObj);
-                    PassFailJFrame.positionTestWindow(testObj, PassFailJFrame.Position.HORIZONTAL);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
+        SwingUtilities.invokeAndWait(() -> {
+            try {
+                passFailJFrame = new PassFailJFrame(instructions);
+                testObj = new TestFrame();
+                //Adding the Test Frame to handle dispose
+                PassFailJFrame.addTestWindow(testObj);
+                PassFailJFrame.positionTestWindow(testObj, PassFailJFrame.Position.HORIZONTAL);
+                testObj.setVisible(true);
+            } catch (Exception e) {
+                e.printStackTrace();
             }
         });
         passFailJFrame.awaitAndCheck();
@@ -111,9 +109,7 @@ class TestFrame extends JFrame implements ActionListener {
         }
 
         getContentPane().add(p,BorderLayout.SOUTH);
-
         setSize(500, 300);
-        setVisible(true);
     }
 
     private static void setLookAndFeel(String laf) {
diff --git a/test/jdk/javax/swing/JTabbedPane/4209065/bug4209065.java b/test/jdk/javax/swing/JTabbedPane/4209065/bug4209065.java
index ee01216b643..3ece69b2f00 100644
--- a/test/jdk/javax/swing/JTabbedPane/4209065/bug4209065.java
+++ b/test/jdk/javax/swing/JTabbedPane/4209065/bug4209065.java
@@ -21,6 +21,13 @@
  * questions.
  */
 
+import java.lang.reflect.InvocationTargetException;
+
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+
 /*
  * @test
  * @bug 4209065
@@ -30,14 +37,6 @@
  * @run main/manual bug4209065
  */
 
-import java.lang.reflect.InvocationTargetException;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTabbedPane;
-import javax.swing.SwingUtilities;
-
-
 public final class bug4209065 {
 
     private static JFrame frame;
@@ -47,37 +46,32 @@ public final class bug4209065 {
                     " text may be larger\nthan the tab height but this is OK" +
                     " and NOT a failure.";
 
-    public static void createAndShowGUI() throws InterruptedException,
-            InvocationTargetException {
-        SwingUtilities.invokeAndWait(() -> {
-            frame = new JFrame("JTabbedPane");
+    public static void createAndShowGUI() {
 
-            JTabbedPane tp = new JTabbedPane();
+        frame = new JFrame("JTabbedPane");
+        JTabbedPane tp = new JTabbedPane();
 
-            tp.addTab("<html><center><font size=+3>big</font></center></html>",
-                    new JLabel());
-            tp.addTab("<html><center><font color=red>red</font></center></html>",
-                    new JLabel());
-            tp.addTab("<html><center><em><b>Bold Italic!</b></em></center></html>",
-                    new JLabel());
+        tp.addTab("<html><center><font size=+3>big</font></center></html>",
+                new JLabel());
+        tp.addTab("<html><center><font color=red>red</font></center></html>",
+                new JLabel());
+        tp.addTab("<html><center><em><b>Bold Italic!</b></em></center></html>",
+                new JLabel());
 
-            frame.getContentPane().add(tp);
-            frame.setSize(400, 400);
-            frame.setLocationRelativeTo(null);
-            frame.setVisible(true);
+        frame.getContentPane().add(tp);
+        frame.setSize(400, 400);
 
-
-            PassFailJFrame.addTestWindow(frame);
-            PassFailJFrame.positionTestWindow(frame,
-                    PassFailJFrame.Position.HORIZONTAL);
-        });
+        PassFailJFrame.addTestWindow(frame);
+        PassFailJFrame.positionTestWindow(frame,
+                PassFailJFrame.Position.HORIZONTAL);
+        frame.setVisible(true);
     }
 
     public static void main(String[] args) throws InterruptedException,
             InvocationTargetException {
         PassFailJFrame passFailJFrame = new PassFailJFrame("JTabbedPane " +
                 "Test Instructions", text, 5, 19, 35);
-        createAndShowGUI();
+        SwingUtilities.invokeAndWait(bug4209065::createAndShowGUI);
         passFailJFrame.awaitAndCheck();
     }
-}
\ No newline at end of file
+}
diff --git a/test/jdk/javax/swing/JTable/PrintAllPagesTest.java b/test/jdk/javax/swing/JTable/PrintAllPagesTest.java
index 5856ebe25da..c91855985f4 100644
--- a/test/jdk/javax/swing/JTable/PrintAllPagesTest.java
+++ b/test/jdk/javax/swing/JTable/PrintAllPagesTest.java
@@ -65,25 +65,21 @@ public class PrintAllPagesTest {
 
         SwingUtilities.invokeAndWait(() -> {
             printAllPagesTest();
-        });
+            // add the test frame to dispose
+            PassFailJFrame.addTestWindow(f);
 
-        // add the test frame to dispose
-        PassFailJFrame.addTestWindow(f);
-
-        // Arrange the test instruction frame and test frame side by side
-        PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
-
-        SwingUtilities.invokeAndWait(() -> {
+            // Arrange the test instruction frame and test frame side by side
+            PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
+            f.setVisible(true);
             try {
                 ret = table.print();
             } catch (PrinterException ex) {
                 ret = false;
             }
+            if (!ret) {
+                throw new RuntimeException("Printing cancelled/failed");
+            }
         });
-
-        if (!ret) {
-            throw new RuntimeException("Printing cancelled/failed");
-        }
         passFailJFrame.awaitAndCheck();
     }
 
@@ -107,11 +103,11 @@ public class PrintAllPagesTest {
         };
         table = new JTable(dataModel);
         JScrollPane scrollpane = new JScrollPane(table);
-        table.scrollRectToVisible(table.getCellRect(table.getRowCount() - 1, 0, false));
+        table.scrollRectToVisible(table.getCellRect(table.getRowCount() - 1,
+                0, false));
 
         f = new JFrame("Table test");
         f.add(scrollpane);
         f.setSize(1000, 800);
-        f.setVisible(true);
     }
 }
diff --git a/test/jdk/javax/swing/text/html/HtmlScriptTagParserTest.java b/test/jdk/javax/swing/text/html/HtmlScriptTagParserTest.java
index 1a533f3ec07..8d11a7de9ee 100644
--- a/test/jdk/javax/swing/text/html/HtmlScriptTagParserTest.java
+++ b/test/jdk/javax/swing/text/html/HtmlScriptTagParserTest.java
@@ -63,13 +63,12 @@ public class HtmlScriptTagParserTest {
 
             frame = new JFrame();
             frame.getContentPane().add(scroll);
-            frame.setVisible(true);
             frame.pack();
-            frame.setLocationRelativeTo(null);
 
             PassFailJFrame.addTestWindow(frame);
             PassFailJFrame.positionTestWindow(frame,
                     PassFailJFrame.Position.HORIZONTAL);
+            frame.setVisible(true);
         });
     }
 
@@ -81,7 +80,6 @@ public class HtmlScriptTagParserTest {
                 "\n\nHTML Used:\n" + htmlText, 5);
 
         createAndShowGUI();
-
         pfjFrame.awaitAndCheck();
     }
 }