10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @key headful
27 * @bug 8024061
28 * @summary Checks that no exception is thrown if dragGestureRecognized
29 * takes a while to complete.
30 * @library ../../../../lib/testlibrary
31 * @build jdk.testlibrary.OSInfo
32 * @run main bug8024061
33 */
34 import java.awt.*;
35 import java.awt.datatransfer.DataFlavor;
36 import java.awt.datatransfer.Transferable;
37 import java.awt.datatransfer.UnsupportedFlavorException;
38 import java.awt.dnd.DnDConstants;
39 import java.awt.dnd.DragGestureEvent;
40 import java.awt.dnd.DragGestureListener;
41 import java.awt.dnd.DragSource;
42 import java.awt.dnd.DragSourceDragEvent;
43 import java.awt.dnd.DragSourceDropEvent;
44 import java.awt.dnd.DragSourceEvent;
45 import java.awt.dnd.DragSourceListener;
46 import java.awt.dnd.DropTarget;
47 import java.awt.dnd.DropTargetDragEvent;
48 import java.awt.dnd.DropTargetDropEvent;
49 import java.awt.dnd.DropTargetEvent;
50 import java.awt.dnd.DropTargetListener;
51 import java.awt.event.InputEvent;
52
53 import java.io.IOException;
54 import java.lang.reflect.InvocationTargetException;
55 import java.util.concurrent.CountDownLatch;
56 import java.util.concurrent.TimeUnit;
57
58 import javax.swing.*;
59 import jdk.testlibrary.OSInfo;
60
61
62 /**
63 * If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
64 * an exception is thrown from DropTargetListener.dragEnter when it calls
65 * DropTargetDragEvent.getTransferable().
66 * <p>
67 * This class introduces a delay in dragGestureRecognized() to cause the exception.
68 */
69 public class bug8024061 {
70 private static final DataFlavor DropObjectFlavor;
71 private static final int DELAY = 1000;
72
73 static final DnDPanel panel1 = new DnDPanel(Color.yellow);
74 static final DnDPanel panel2 = new DnDPanel(Color.pink);
75 private final JFrame frame;
76 static Point here;
77 static Point there;
78 static Dimension d;
79
80
97 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
98
99 d = new Dimension(100, 100);
100
101 panel1.setPreferredSize(d);
102 panel2.setPreferredSize(d);
103
104 Container content = frame.getContentPane();
105 content.setLayout(new GridLayout(1, 2, 5, 5));
106 content.add(panel1);
107 content.add(panel2);
108
109 frame.pack();
110
111 DropObject drop = new DropObject();
112 drop.place(panel1, new Point(10, 10));
113 frame.setVisible(true);
114 }
115
116 public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
117 OSInfo.OSType type = OSInfo.getOSType();
118 if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
119 System.out.println("This test is for Linux and Solaris only... " +
120 "skipping!");
121 return;
122 }
123
124 final bug8024061[] dnd = {null};
125 SwingUtilities.invokeAndWait(new Runnable() {
126 @Override
127 public void run() {
128 dnd[0] = new bug8024061();
129 }
130 });
131 final Robot robot = new Robot();
132 robot.setAutoDelay(10);
133 robot.waitForIdle();
134 robot.delay(200);
135
136 JFrame frame = dnd[0].frame;
137 SwingUtilities.invokeAndWait(() -> {
138 here = panel1.getLocationOnScreen();
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @key headful
27 * @bug 8024061
28 * @summary Checks that no exception is thrown if dragGestureRecognized
29 * takes a while to complete.
30 * @library /test/lib
31 * @build jdk.test.lib.Platform
32 * @run main bug8024061
33 */
34 import java.awt.*;
35 import java.awt.datatransfer.DataFlavor;
36 import java.awt.datatransfer.Transferable;
37 import java.awt.datatransfer.UnsupportedFlavorException;
38 import java.awt.dnd.DnDConstants;
39 import java.awt.dnd.DragGestureEvent;
40 import java.awt.dnd.DragGestureListener;
41 import java.awt.dnd.DragSource;
42 import java.awt.dnd.DragSourceDragEvent;
43 import java.awt.dnd.DragSourceDropEvent;
44 import java.awt.dnd.DragSourceEvent;
45 import java.awt.dnd.DragSourceListener;
46 import java.awt.dnd.DropTarget;
47 import java.awt.dnd.DropTargetDragEvent;
48 import java.awt.dnd.DropTargetDropEvent;
49 import java.awt.dnd.DropTargetEvent;
50 import java.awt.dnd.DropTargetListener;
51 import java.awt.event.InputEvent;
52
53 import java.io.IOException;
54 import java.lang.reflect.InvocationTargetException;
55 import java.util.concurrent.CountDownLatch;
56 import java.util.concurrent.TimeUnit;
57
58 import javax.swing.*;
59
60 import jdk.test.lib.Platform;
61
62 /**
63 * If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
64 * an exception is thrown from DropTargetListener.dragEnter when it calls
65 * DropTargetDragEvent.getTransferable().
66 * <p>
67 * This class introduces a delay in dragGestureRecognized() to cause the exception.
68 */
69 public class bug8024061 {
70 private static final DataFlavor DropObjectFlavor;
71 private static final int DELAY = 1000;
72
73 static final DnDPanel panel1 = new DnDPanel(Color.yellow);
74 static final DnDPanel panel2 = new DnDPanel(Color.pink);
75 private final JFrame frame;
76 static Point here;
77 static Point there;
78 static Dimension d;
79
80
97 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
98
99 d = new Dimension(100, 100);
100
101 panel1.setPreferredSize(d);
102 panel2.setPreferredSize(d);
103
104 Container content = frame.getContentPane();
105 content.setLayout(new GridLayout(1, 2, 5, 5));
106 content.add(panel1);
107 content.add(panel2);
108
109 frame.pack();
110
111 DropObject drop = new DropObject();
112 drop.place(panel1, new Point(10, 10));
113 frame.setVisible(true);
114 }
115
116 public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
117 if (!Platform.isLinux() && !Platform.isSolaris()) {
118 System.out.println("This test is for Linux and Solaris only... " +
119 "skipping!");
120 return;
121 }
122
123 final bug8024061[] dnd = {null};
124 SwingUtilities.invokeAndWait(new Runnable() {
125 @Override
126 public void run() {
127 dnd[0] = new bug8024061();
128 }
129 });
130 final Robot robot = new Robot();
131 robot.setAutoDelay(10);
132 robot.waitForIdle();
133 robot.delay(200);
134
135 JFrame frame = dnd[0].frame;
136 SwingUtilities.invokeAndWait(() -> {
137 here = panel1.getLocationOnScreen();
|