diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt
index 303e449e4a5..664a7ac02da 100644
--- a/test/jdk/ProblemList.txt
+++ b/test/jdk/ProblemList.txt
@@ -437,6 +437,7 @@ java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.j
java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java 7107528 linux-all,macosx-all
java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java 8080676 linux-all
java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersInKeyEvent.java 8157147 linux-all,windows-all,macosx-all
+java/awt/Mouse/MouseClickCount.java 8017182 macosx-all
java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java 6847163 linux-all
java/awt/xembed/server/RunTestXEmbed.java 7034201 linux-all
java/awt/Modal/ModalFocusTransferTests/FocusTransferDialogsDocModalTest.java 8164473 linux-all
diff --git a/test/jdk/java/awt/GraphicsEnvironment/DefaultScreenDeviceTest.java b/test/jdk/java/awt/GraphicsEnvironment/DefaultScreenDeviceTest.java
new file mode 100644
index 00000000000..b59460322da
--- /dev/null
+++ b/test/jdk/java/awt/GraphicsEnvironment/DefaultScreenDeviceTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Label;
+import java.awt.Rectangle;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 4473671
+ * @summary Test to verify GraphicsEnvironment.getDefaultScreenDevice always
+ * returning first screen
+ * @requires (os.family == "windows")
+ * @library /java/awt/regtesthelpers
+ * @build PassFailJFrame
+ * @run main/manual DefaultScreenDeviceTest
+ */
+
+public class DefaultScreenDeviceTest {
+ private static Frame testFrame;
+
+ public static void main(String[] args) throws Exception {
+ GraphicsEnvironment ge = GraphicsEnvironment.
+ getLocalGraphicsEnvironment();
+ GraphicsDevice[] gds = ge.getScreenDevices();
+ if (gds.length < 2) {
+ System.out.println("Test requires at least 2 displays");
+ return;
+ }
+
+ String INSTRUCTIONS = """
+ 1. The test is for systems which allows primary display
+ selection in multiscreen systems.
+ Set the system primary screen to be the rightmost
+ (i.e. the right screen in two screen configuration)
+ This can be done by going to OS Display Settings
+ selecting the screen and checking the 'Use this device
+ as primary monitor' checkbox.
+ 2. When done, click on 'Frame on Primary Screen' button and
+ see where the frame will pop up
+ 3. If Primary Frame pops up on the primary display,
+ the test passed, otherwise it failed
+ """;
+ PassFailJFrame.builder()
+ .title("Test Instructions")
+ .instructions(INSTRUCTIONS)
+ .rows((int) INSTRUCTIONS.lines().count() + 2)
+ .columns(35)
+ .testUI(initialize())
+ .build()
+ .awaitAndCheck();
+ }
+
+ private static List initialize() {
+ Frame frame = new Frame("Default screen device test");
+ GraphicsConfiguration gc =
+ GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice().getDefaultConfiguration();
+
+ testFrame = new Frame("Primary screen frame", gc);
+ frame.setLayout(new BorderLayout());
+ frame.setSize(200, 200);
+
+ Button b = new Button("Frame on Primary Screen");
+ b.addActionListener(e -> {
+ if (testFrame != null) {
+ testFrame.setVisible(false);
+ testFrame.dispose();
+ }
+
+ testFrame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e1) {
+ testFrame.setVisible(false);
+ testFrame.dispose();
+ }
+ });
+ testFrame.add(new Label("This frame should be on the primary screen"));
+ testFrame.setBackground(Color.red);
+ testFrame.pack();
+ Rectangle rect = gc.getBounds();
+ testFrame.setLocation(rect.x + 100, rect.y + 100);
+ testFrame.setVisible(true);
+ });
+ frame.add(b);
+ return List.of(testFrame, frame);
+ }
+}
diff --git a/test/jdk/java/awt/Mouse/DoubleClickTest.java b/test/jdk/java/awt/Mouse/DoubleClickTest.java
new file mode 100644
index 00000000000..037332a4098
--- /dev/null
+++ b/test/jdk/java/awt/Mouse/DoubleClickTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Event;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.TextArea;
+
+/*
+ * @test
+ * @bug 4092370
+ * @summary Test to verify double click
+ * @library /java/awt/regtesthelpers
+ * @build PassFailJFrame
+ * @run main/manual DoubleClickTest
+ */
+
+public class DoubleClickTest {
+ static TextArea ta = new TextArea("", 10, 40);
+
+ public static void main(String[] args) throws Exception {
+ String INSTRUCTIONS = """
+ 1. Double click on the red area.
+ 2. Verify that the event reports click_count > 1 on
+ Double-Click. If click_count shows only 1 for every
+ Double-Clicks then test FAILS, else test PASS.
+ """;
+ PassFailJFrame.builder()
+ .title("Test Instructions")
+ .instructions(INSTRUCTIONS)
+ .rows((int) INSTRUCTIONS.lines().count() + 2)
+ .columns(35)
+ .testUI(initialize())
+ .build()
+ .awaitAndCheck();
+ }
+
+ public static Frame initialize() {
+ Frame frame = new Frame("Double-click Test");
+ frame.setLayout(new BorderLayout());
+ frame.add("East", new MyPanel(ta));
+ frame.add("West", ta);
+ frame.setSize(200, 200);
+ return frame;
+ }
+}
+
+class MyPanel extends Panel {
+ TextArea ta;
+
+ MyPanel(TextArea ta) {
+ this.ta = ta;
+ setBackground(Color.red);
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(50, 50);
+ }
+
+
+ public boolean mouseDown(Event event, int x, int y) {
+ ta.append("event click count= " + event.clickCount + "\n");
+ return false;
+ }
+}
diff --git a/test/jdk/java/awt/Mouse/MouseClickCount.java b/test/jdk/java/awt/Mouse/MouseClickCount.java
new file mode 100644
index 00000000000..a63d24fcb9f
--- /dev/null
+++ b/test/jdk/java/awt/Mouse/MouseClickCount.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Frame;
+import java.awt.TextArea;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/*
+ * @test
+ * @bug 4199397
+ * @summary Test to mouse click count
+ * @library /java/awt/regtesthelpers
+ * @build PassFailJFrame
+ * @run main/manual MouseClickCount
+ */
+
+public class MouseClickCount {
+ public static void main(String[] args) throws Exception {
+ String INSTRUCTIONS = """
+ 1. Clicking on Frame panel quickly will produce clickCount larger than 1
+ in the TextArea the count is printed for each mouse click
+ 2. Verify that a left-button click followed by a right button click quickly
+ will not generate 1, 2, i.e. it's not considered a double clicking.
+ """;
+ PassFailJFrame.builder()
+ .title("Test Instructions")
+ .instructions(INSTRUCTIONS)
+ .rows((int) INSTRUCTIONS.lines().count() + 2)
+ .columns(35)
+ .testUI(initialize())
+ .build()
+ .awaitAndCheck();
+ }
+
+ private static Frame initialize() {
+ Frame f = new Frame("Mouse Click Count Test");
+ final TextArea ta = new TextArea();
+ f.add("South", ta);
+ f.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent e) {
+ if (e.getClickCount() == 1) ta.append("\n1");
+ else ta.append(", " + e.getClickCount());
+ }
+ });
+ f.setSize(300, 500);
+ return f;
+ }
+}
diff --git a/test/jdk/java/awt/Mouse/MouseDragEnterExitTest.java b/test/jdk/java/awt/Mouse/MouseDragEnterExitTest.java
new file mode 100644
index 00000000000..b2d8e446ffc
--- /dev/null
+++ b/test/jdk/java/awt/Mouse/MouseDragEnterExitTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 4141361
+ * @summary Test to Ensures that mouse enter / exit is delivered to a new
+ * frame or component during a drag
+ * @library /java/awt/regtesthelpers
+ * @build PassFailJFrame
+ * @run main/manual MouseDragEnterExitTest
+ */
+
+public class MouseDragEnterExitTest {
+ public static void main(String[] args) throws Exception {
+ String INSTRUCTIONS = """
+ Click on the blue frame, drag to the white frame, and back
+ You should get enter/exit messages for the frames when dragging
+ """;
+ PassFailJFrame.builder()
+ .title("Test Instructions")
+ .instructions(INSTRUCTIONS)
+ .rows((int) INSTRUCTIONS.lines().count() + 2)
+ .columns(35)
+ .testUI(MouseEvents.initialize())
+ .logArea(8)
+ .build()
+ .awaitAndCheck();
+ }
+}
+
+class MouseEvents extends Frame {
+ static int WITH_WIDGET = 0;
+
+ public MouseEvents(int mode) {
+ super("Mouse Drag Enter/Exit Test");
+ setSize(300, 300);
+
+ addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ PassFailJFrame.log("Frame MOUSE_ENTERED" + ": " + " " +
+ e.getX() + " " + e.getY());
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ PassFailJFrame.log("Frame MOUSE_EXITED" + ": " + " " +
+ e.getX() + " " + e.getY());
+ }
+ });
+
+ if (mode == WITH_WIDGET) {
+ setLayout(new BorderLayout());
+ add("Center", new SimplePanel());
+ }
+ }
+
+ public static List initialize() {
+ MouseEvents m = new MouseEvents(MouseEvents.WITH_WIDGET);
+ m.setLocation(500, 300);
+ MouseEvents t = new MouseEvents(MouseEvents.WITH_WIDGET + 1);
+ t.setLocation(200, 200);
+ return List.of(m, t);
+ }
+}
+
+class SimplePanel extends Panel {
+ public SimplePanel() {
+ super();
+ setName("Test Panel");
+ addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ PassFailJFrame.log("Panel MOUSE_ENTERED" + ": " + " " +
+ e.getX() + " " + e.getY());
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ PassFailJFrame.log("Panel MOUSE_EXITED" + ": " + " " +
+ e.getX() + " " + e.getY());
+ }
+ });
+ setSize(100, 100);
+ setBackground(Color.blue);
+ }
+}
+
diff --git a/test/jdk/java/awt/Mouse/MouseDragTest.java b/test/jdk/java/awt/Mouse/MouseDragTest.java
new file mode 100644
index 00000000000..cb8be7b0de2
--- /dev/null
+++ b/test/jdk/java/awt/Mouse/MouseDragTest.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionAdapter;
+import java.awt.event.MouseMotionListener;
+
+/*
+ * @test
+ * @bug 4035189
+ * @summary Test to verify that Drag events go to wrong component
+ * @library /java/awt/regtesthelpers
+ * @build PassFailJFrame
+ * @run main/manual MouseDragTest
+ */
+
+class HeavySquare extends Canvas {
+ private final Color colorNormal;
+ private boolean gotADragEvent;
+
+ public HeavySquare(Color color) {
+ colorNormal = color;
+ setBackground(colorNormal);
+ new MouseChecker(this);
+ addMouseMotionListener(new DragAdapter());
+ addMouseListener(new PressReleaseAdapter());
+ }
+
+ class DragAdapter extends MouseMotionAdapter {
+ public void mouseDragged(MouseEvent ev) {
+ if (gotADragEvent)
+ return;
+
+ Point mousePt = ev.getPoint();
+ Dimension csize = getSize();
+ boolean inBounds =
+ (mousePt.x >= 0 && mousePt.x <= csize.width &&
+ mousePt.y >= 0 && mousePt.y <= csize.height);
+ if (!inBounds) {
+ setBackground(Color.green);
+ }
+ gotADragEvent = true;
+ }
+ }
+
+ class PressReleaseAdapter extends MouseAdapter {
+ public void mousePressed(MouseEvent ev) {
+ gotADragEvent = false;
+ }
+
+ public void mouseReleased(MouseEvent ev) {
+ setBackground(colorNormal);
+ }
+ }
+
+ public Dimension preferredSize() {
+ return new Dimension(50, 50);
+ }
+}
+
+class MouseFrame extends Frame {
+ public MouseFrame() {
+ super("MouseDragTest");
+ new MouseChecker(this);
+ setLayout(new FlowLayout());
+ add(new HeavySquare(Color.red));
+ add(new HeavySquare(Color.blue));
+ setBounds(new Rectangle(20, 20, 400, 300));
+ }
+}
+
+public class MouseDragTest {
+ static Frame TestFrame;
+
+ public MouseDragTest() {
+ TestFrame = new MouseFrame();
+ }
+
+ public static void main(String[] args) throws Exception {
+ String INSTRUCTIONS = """
+ 1. A frame with two boxes will appear. Click and drag _very_ quickly
+ off one of the components. You will know you were quick enough
+ when the component you dragged off of turns green
+ 2. Repeat this several times on both boxes, ensuring you get them
+ to turn green. The components should revert to their original
+ color when you release the mouse
+ 3. The test FAILS if the component doesn't revert to original
+ color, else PASS.
+ """;
+ PassFailJFrame.builder()
+ .title("Test Instructions")
+ .instructions(INSTRUCTIONS)
+ .rows((int) INSTRUCTIONS.lines().count() + 2)
+ .columns(35)
+ .testUI(new MouseFrame())
+ .build()
+ .awaitAndCheck();
+ }
+}
+
+class MouseChecker implements MouseListener, MouseMotionListener {
+ private boolean isPressed = false;
+ private MouseEvent evPrev = null;
+ private MouseEvent evPrevPrev = null;
+
+ public MouseChecker(Component comp) {
+ comp.addMouseListener(this);
+ comp.addMouseMotionListener(this);
+ }
+
+ private void recordEv(MouseEvent ev) {
+ evPrevPrev = evPrev;
+ evPrev = ev;
+ }
+
+ private synchronized void failure(String str) {
+ PassFailJFrame.forceFail("Test Failed : "+str);
+ }
+
+ public void mouseClicked(MouseEvent ev) {
+ if (!(evPrev.getID() == MouseEvent.MOUSE_RELEASED &&
+ evPrevPrev.getID() == MouseEvent.MOUSE_PRESSED)) {
+ failure("Got mouse click without press/release preceding.");
+ }
+ recordEv(ev);
+ }
+
+ public void mousePressed(MouseEvent ev) {
+ recordEv(ev);
+ if (isPressed) {
+ failure("Got two mouse presses without a release.");
+ }
+ isPressed = true;
+ }
+
+ public void mouseReleased(MouseEvent ev) {
+ recordEv(ev);
+ if (!isPressed) {
+ failure("Got mouse release without being pressed.");
+ }
+ isPressed = false;
+ }
+
+ public void mouseEntered(MouseEvent ev) {
+ recordEv(ev);
+ Point mousePt = ev.getPoint();
+ Component comp = (Component) ev.getSource();
+ Dimension size = comp.getSize();
+ boolean inBounds =
+ (mousePt.x >= 0 && mousePt.x <= size.width &&
+ mousePt.y >= 0 && mousePt.y <= size.height);
+
+ if (!inBounds) {
+ failure("Got mouse entered, but mouse not inside component.");
+ }
+ }
+
+ public void mouseExited(MouseEvent ev) {
+ recordEv(ev);
+ Point mousePt = ev.getPoint();
+ Component comp = (Component) ev.getSource();
+ if (comp instanceof Frame) {
+ return;
+ }
+ Dimension size = comp.getSize();
+ boolean isOnChild = (comp != comp.getComponentAt(mousePt));
+ boolean inBounds =
+ (mousePt.x >= 0 && mousePt.x <= size.width &&
+ mousePt.y >= 0 && mousePt.y <= size.height);
+ if (!isOnChild && inBounds) {
+ failure("Got mouse exit, but mouse still inside component.");
+ }
+ }
+
+ public void mouseDragged(MouseEvent ev) {
+ recordEv(ev);
+ if (!isPressed) {
+ failure("Got drag without a press first.");
+ }
+ }
+
+ public void mouseMoved(MouseEvent ev) {
+ recordEv(ev);
+ }
+}