author | hseigel |
Wed, 01 Mar 2017 08:00:02 -0500 | |
changeset 46194 | 5596e6f63072 |
parent 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
36885
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
1 |
/* |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
4 |
* |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
8 |
* |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
14 |
* |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
18 |
* |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
21 |
* questions. |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
22 |
*/ |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
23 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
24 |
import java.awt.BorderLayout; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
25 |
import java.awt.Component; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
26 |
import java.awt.Dimension; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
27 |
import java.awt.Point; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
28 |
import java.awt.Robot; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
29 |
import java.awt.event.InputEvent; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
30 |
import javax.swing.JFrame; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
31 |
import javax.swing.JPanel; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
32 |
import javax.swing.JTextArea; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
33 |
import javax.swing.SwingUtilities; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
34 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
35 |
/** |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
36 |
* @test |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
36885
diff
changeset
|
37 |
* @key headful |
36885
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
38 |
* @bug 8149849 |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
39 |
* @summary [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
40 |
* other text component) when scale > 1 |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
41 |
* @run main/othervm -Dsun.java2d.uiScale=2 DNDTextToScaledArea |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
42 |
*/ |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
43 |
public class DNDTextToScaledArea { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
44 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
45 |
private static final String TEXT = "ABCDEFGH"; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
46 |
private static JFrame frame; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
47 |
private static JTextArea srcTextArea; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
48 |
private static JTextArea dstTextArea; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
49 |
private static volatile Point srcPoint; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
50 |
private static volatile Point dstPoint; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
51 |
private static volatile boolean passed = false; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
52 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
53 |
public static void main(String[] args) throws Exception { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
54 |
Robot robot = new Robot(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
55 |
robot.setAutoDelay(50); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
56 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
57 |
SwingUtilities.invokeAndWait(DNDTextToScaledArea::createAndShowGUI); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
58 |
robot.waitForIdle(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
59 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
60 |
SwingUtilities.invokeAndWait(() -> { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
61 |
srcPoint = getPoint(srcTextArea, 0.1); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
62 |
dstPoint = getPoint(dstTextArea, 0.75); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
63 |
}); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
64 |
robot.waitForIdle(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
65 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
66 |
dragAndDrop(robot, srcPoint, dstPoint); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
67 |
robot.waitForIdle(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
68 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
69 |
SwingUtilities.invokeAndWait(() -> { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
70 |
passed = TEXT.equals(dstTextArea.getText()); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
71 |
frame.dispose(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
72 |
}); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
73 |
robot.waitForIdle(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
74 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
75 |
if (!passed) { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
76 |
throw new RuntimeException("Text Drag and Drop failed!"); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
77 |
} |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
78 |
} |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
79 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
80 |
private static void createAndShowGUI() { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
81 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
82 |
frame = new JFrame(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
83 |
frame.setSize(300, 300); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
84 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
85 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
86 |
JPanel panel = new JPanel(new BorderLayout()); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
87 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
88 |
srcTextArea = new JTextArea(TEXT); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
89 |
srcTextArea.setDragEnabled(true); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
90 |
srcTextArea.selectAll(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
91 |
dstTextArea = new JTextArea(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
92 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
93 |
panel.add(dstTextArea, BorderLayout.CENTER); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
94 |
panel.add(srcTextArea, BorderLayout.SOUTH); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
95 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
96 |
frame.getContentPane().add(panel); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
97 |
frame.setVisible(true); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
98 |
} |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
99 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
100 |
private static Point getPoint(Component component, double scale) { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
101 |
Point point = component.getLocationOnScreen(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
102 |
Dimension bounds = component.getSize(); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
103 |
point.translate((int) (bounds.width * scale), (int) (bounds.height * scale)); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
104 |
return point; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
105 |
} |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
106 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
107 |
public static void dragAndDrop(Robot robot, Point src, Point dst) throws Exception { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
108 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
109 |
int x1 = src.x; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
110 |
int y1 = src.y; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
111 |
int x2 = dst.x; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
112 |
int y2 = dst.y; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
113 |
robot.mouseMove(x1, y1); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
114 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
115 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
116 |
float dmax = (float) Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1)); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
117 |
float dx = (x2 - x1) / dmax; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
118 |
float dy = (y2 - y1) / dmax; |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
119 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
120 |
for (int i = 0; i <= dmax; i += 5) { |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
121 |
robot.mouseMove((int) (x1 + dx * i), (int) (y1 + dy * i)); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
122 |
} |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
123 |
|
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
124 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
125 |
} |
75de89bc3d0d
8149849: [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or other text component) when scale > 1
alexsch
parents:
diff
changeset
|
126 |
} |