< prev index next >
test/java/awt/dnd/Button2DragTest/Button2DragTest.java
Print this page
rev 14294 : 7124381: DragSourceListener.dragDropEnd() never been called on completion of dnd operation
Reviewed-by: xxx
rev 8985 : 8032058: [TEST_BUG] [macosx] java/awt/dnd/Button2DragTest sometimes fail
Reviewed-by: anthony, serb
rev 2362 : 6943119: Rebrand source copyright notices
Reviewed-by: darcy, weijun
rev 0 : Initial load
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -19,49 +19,56 @@
* 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.
*/
-/*
- 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 static void main(final String[] args) {
+ Button2DragTest test = new Button2DragTest();
+ try {
+ test.run();
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+ }
- public void init() {
- // Set up the environment -- set the layout manager, add
- // buttons, etc.
- setLayout(new BorderLayout());
-
+ public void run() {
frame = new Frame();
final DragSourceListener dragSourceListener = new DragSourceAdapter() {
public void dragDropEnd(DragSourceDropEvent e) {
dropSuccess = e.getDropSuccess();
@@ -82,24 +89,17 @@
dtde.dropComplete(true);
System.err.println("Drop");
}
};
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();
Util.waitForIdle(robot);
< prev index next >