7124381: DragSourceListener.dragDropEnd() never been called on completion of dnd operation
authorserb
Mon, 25 Apr 2016 19:14:30 +0300
changeset 38383 c76fffbf4ef5
parent 37714 7a0b1c7e7054
child 38384 05e90f2c9ab8
7124381: DragSourceListener.dragDropEnd() never been called on completion of dnd operation Reviewed-by: yan, ssadetsky
jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html
jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html	Mon Apr 25 15:09:45 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<!--
- Copyright (c) 2006, 2013, 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.
--->
-
-<html>
-<!--
-  @test
-  @bug 4955110
-  @summary tests that a drag ends on button2 release
-  @author Alexander.Gerasimov area=dnd
-  @library    ../../regtesthelpers
-  @build      Util
-  @run applet/othervm Button2DragTest.html
-  -->
-<head>
-<title>  </title>
-</head>
-<body>
-
-<h1>Button2DragTest<br>Bug ID: 4955110</h1>
-
-<p> This is an AUTOMATIC test, simply wait for completion </p>
-
-<APPLET CODE="Button2DragTest.class" WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
--- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java	Mon Apr 25 15:09:45 2016 -0700
+++ b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java	Mon Apr 25 19:14:30 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -21,45 +21,52 @@
  * questions.
  */
 
-/*
-  test
-  @bug 4955110
-  @summary tests that a drag ends on button2 release
-  @author Alexander.Gerasimov area=dnd
-  @library    ../../regtesthelpers
-  @build      Util
-  @run applet/othervm Button2DragTest.html
-*/
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.datatransfer.StringSelection;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
 
+import test.java.awt.regtesthelpers.Util;
 
 /**
- * Button2DragTest.java
- *
- * summary: tests that DragSourceDragEvent.getDropAction() accords to its new spec
- *          (does not depend on the user drop action)
- *
+ * @test
+ * @bug 4955110
+ * @summary tests that DragSourceDragEvent.getDropAction() accords to its new
+ *          spec (does not depend on the user drop action)
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/othervm Button2DragTest
+ * @author Alexander.Gerasimov area=dnd
  */
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.datatransfer.*;
-import java.awt.dnd.*;
-import test.java.awt.regtesthelpers.Util;
-
-
-public class Button2DragTest extends Applet {
+public final class Button2DragTest {
 
     private volatile boolean dropSuccess;
 
-    private Frame frame;
-
+    private static Frame frame;
 
-    public void init() {
-        // Set up the environment -- set the layout manager, add
-        // buttons, etc.
-        setLayout(new BorderLayout());
+    public static void main(final String[] args) {
+        Button2DragTest test = new Button2DragTest();
+        try {
+            test.run();
+        } finally {
+            if (frame != null) {
+                frame.dispose();
+            }
+        }
+    }
 
+    public void run() {
         frame = new Frame();
 
         final DragSourceListener dragSourceListener = new DragSourceAdapter() {
@@ -84,20 +91,13 @@
             }
         };
         new DropTarget(frame, dropTargetListener);
-    }
-
-
-    public void start() {
-        //Get things going.  Request focus, set size, et cetera
-        setSize(200,200);
-        setVisible(true);
-        validate();
 
         //What would normally go into main() will probably go here.
         //Use System.out.println for diagnostic messages that you want
         //to read after the test is done.
-
+        frame.setUndecorated(true);
         frame.setBounds(100, 100, 200, 200);
+        frame.setLocationRelativeTo(null);
         frame.setVisible(true);
 
         Robot robot = Util.createRobot();