-
Bug
-
Resolution: Fixed
-
P4
-
11, 15, 16, 17
-
b12
-
x86_64
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8265053 | 15.0.4 | Olga Mikhaltcova | P4 | Resolved | Fixed | b01 |
JDK-8263647 | 13.0.7 | Olga Mikhaltcova | P4 | Resolved | Fixed | b04 |
JDK-8263913 | 11.0.12-oracle | Dukebot | P4 | Resolved | Fixed | b01 |
JDK-8263444 | 11.0.12 | Sergey Bylokhov | P4 | Resolved | Fixed | b01 |
The area of a drop target that actually responds to events is calculated incorrectly on high DPI linux systems. The position of the frame relative to the overall space available on the monitor also seems to have something to do with it.
The attached example should print to the console when something is dragged over the panel bordered in red. It does not respond correctly on high DPI systems unless disable high DPI scaling completely with -Dsun.java2d.uiScale.enabled=false
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Drag any file into the red outline.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Drop events are printed to the console anywhere in the red outline.
ACTUAL -
Only some areas of the frame result in drop events being printed, depending where the frame is located on your monitor.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JPanel;
class Scratch {
public static void main(String[] args) {
JFrame frame = new JFrame("Drag n Drop Test");
frame.setSize(640, 480);
frame.setLayout(new BorderLayout());
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createLineBorder(Color.RED));
panel.setSize(320, 240);
panel.setPreferredSize(new Dimension(320, 240));
panel.setMaximumSize(new Dimension(320, 240));
new DropTarget(panel, new DropTargetListener() {
@Override
public void dragEnter(DropTargetDragEvent dtde) {
System.out.println("dragEnter");
}
@Override
public void dragOver(DropTargetDragEvent dtde) {
System.out.println("dragOver");
}
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
System.out.println("dropActionChanged");
}
@Override
public void dragExit(DropTargetEvent dte) {
System.out.println("dragExit");
}
@Override
public void drop(DropTargetDropEvent dtde) {
System.out.println("drop");
}
});
frame.add(Box.createVerticalStrut(120), BorderLayout.NORTH);
frame.add(Box.createVerticalStrut(120), BorderLayout.SOUTH);
frame.add(Box.createHorizontalStrut(160), BorderLayout.WEST);
frame.add(Box.createHorizontalStrut(160), BorderLayout.EAST);
frame.add(panel, BorderLayout.CENTER);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8263444 Drag n Drop target area is wrong on high DPI systems
- Resolved
-
JDK-8263647 Drag n Drop target area is wrong on high DPI systems
- Resolved
-
JDK-8263913 Drag n Drop target area is wrong on high DPI systems
- Resolved
-
JDK-8265053 Drag n Drop target area is wrong on high DPI systems
- Resolved
- links to
-
Commit openjdk/jdk13u-dev/5850c58e
-
Commit openjdk/jdk15u-dev/44c196aa
-
Commit openjdk/jdk/d3398324
-
Review openjdk/jdk13u-dev/148
-
Review openjdk/jdk15u-dev/21
-
Review openjdk/jdk/1907