Relates :
|
FULL PRODUCT VERSION : OpenJDK 64-Bit Server VM (build 1.9.0-internal-hendrik_2015_03_26_15_38-b00, mixed mode) However, the same thing is true of 8u40. ADDITIONAL OS VERSION INFORMATION : Darwin Mankell 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64 A DESCRIPTION OF THE PROBLEM : javax.swing.TransferHandler supports a custom image that appears when dragging via setDragImage(Image). When provided a MultiResolutionImage on OSX the higher resolution is unfortunately ignored. The reason for this is that in sun.lwawt.macosx.CImage the necessary adjustment for MultiResolutionImage was apparently forgotten for the method createFromImageImmediately(), which is called from the drag mechanism. A JDK9 patch can be found at https://www.beatunes.com/download/webrev-multiresolutiondragimage.zip STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Execute test case below. A window appears with a text field. Drag the content of the text field. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - On a Retina display, the drag image should be RED. On a regular display, the drag image should be BLUE. ACTUAL - The drag image is always BLUE. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import sun.awt.image.MultiResolutionToolkitImage; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; public class MultiResolutionsDragImage { public static void main(String[] args) { SwingUtilities.invokeLater(() -> { final JFrame frame = new JFrame(); frame.setBounds(100, 100, 300, 300); final JTextField label = new JTextField("Drag Me"); label.setDragEnabled(true); final TransferHandler transferHandler = label.getTransferHandler(); transferHandler.setDragImage(createMultiResolutionImage()); frame.getContentPane().add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }); } private static Image createMultiResolutionImage() { return new MultiResolutionToolkitImage(createImage(50, Color.BLUE), createImage(100, Color.RED)); } private static Image createImage(final int length, final Color color) { final BufferedImage image = new BufferedImage(length, length, BufferedImage.TYPE_INT_ARGB_PRE); final Graphics graphics = image.getGraphics(); graphics.setColor(color); graphics.fillRect(0, 0, length, length); graphics.dispose(); return image; } } ---------- END SOURCE ----------