-
Bug
-
Resolution: Not an Issue
-
P4
-
8u144
-
x86
-
os_x
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin 15.6.0 Darwin Kernel Version 15.6.0: Sun Jun 4 21:43:07 PDT 2017; root:xnu-3248.70.3~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Dragging a component - as per the test program - does not work in subdialogs (It does work in a window component).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See Test-Porgram
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Dragging works
ACTUAL -
Dragging does not work
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
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.DragSourceDragEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTargetAdapter;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.io.IOException;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextArea;
public class Drag {
private static JTextArea console = new JTextArea();
static public void main(String[] s) {
JFrame f = new JFrame();
f.setSize(800, 600);
f.getContentPane().setLayout(new BorderLayout());
f.getContentPane().add(new JButton(openDialog(f)), BorderLayout.NORTH);
f.getContentPane().add(console, BorderLayout.CENTER);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
private static Action openDialog(JFrame f) {
return new AbstractAction("open Drag'n'Drop Dialog"){
public void actionPerformed(ActionEvent e) {
JDialog dialog = new JDialog(f);
dialog.getContentPane().setLayout(new BorderLayout());
JList<String> list = new JList<String>(new String[]{"drag me ->"});
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_COPY_OR_MOVE, new DragGesture());
JLabel lbl = new JLabel("drop here");
lbl.setDropTarget(new DropTarget(lbl));
dialog.getContentPane().add(list, BorderLayout.WEST);
dialog.getContentPane().add(lbl, BorderLayout.CENTER);
dialog.setSize(300, 180);
dialog.setLocationRelativeTo(f);
dialog.setVisible(true);
}
};
}
static class DragGesture implements DragGestureListener {
public void dragGestureRecognized(DragGestureEvent dge) {
console.setText(console.getText() + "\ndragGesture: \t" + dge.toString());
Transferable transferable =new Transferable() {
public boolean isDataFlavorSupported(DataFlavor flavor) {
return true;
}
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{DataFlavor.stringFlavor};
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
return "transferData";
}
};
DragSourceListener sourceListener = new DragSourceAdapter() {
public void dragExit(DragSourceEvent dse) {
console.setText(console.getText() + "\ndragExit: \t" + dse.toString());
}
public void dragEnter(DragSourceDragEvent dsde) {
console.setText(console.getText() + "\ndragEnter: \t" + dsde.toString());
}
};
dge.startDrag(DragSource.DefaultCopyDrop, transferable, sourceListener);
}
}
static class DropTarget extends java.awt.dnd.DropTarget {
public DropTarget(JLabel lbl) {
super(lbl, new DropTargetAdapter() {
public void drop(DropTargetDropEvent dtde) {
try {
lbl.setText(dtde.getTransferable().getTransferData(DataFlavor.stringFlavor).toString());
} catch (Exception e) {
console.setText(e.getMessage());
}
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
}
});
}
}
}
---------- END SOURCE ----------
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin 15.6.0 Darwin Kernel Version 15.6.0: Sun Jun 4 21:43:07 PDT 2017; root:xnu-3248.70.3~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Dragging a component - as per the test program - does not work in subdialogs (It does work in a window component).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See Test-Porgram
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Dragging works
ACTUAL -
Dragging does not work
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
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.DragSourceDragEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTargetAdapter;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.io.IOException;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextArea;
public class Drag {
private static JTextArea console = new JTextArea();
static public void main(String[] s) {
JFrame f = new JFrame();
f.setSize(800, 600);
f.getContentPane().setLayout(new BorderLayout());
f.getContentPane().add(new JButton(openDialog(f)), BorderLayout.NORTH);
f.getContentPane().add(console, BorderLayout.CENTER);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
private static Action openDialog(JFrame f) {
return new AbstractAction("open Drag'n'Drop Dialog"){
public void actionPerformed(ActionEvent e) {
JDialog dialog = new JDialog(f);
dialog.getContentPane().setLayout(new BorderLayout());
JList<String> list = new JList<String>(new String[]{"drag me ->"});
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_COPY_OR_MOVE, new DragGesture());
JLabel lbl = new JLabel("drop here");
lbl.setDropTarget(new DropTarget(lbl));
dialog.getContentPane().add(list, BorderLayout.WEST);
dialog.getContentPane().add(lbl, BorderLayout.CENTER);
dialog.setSize(300, 180);
dialog.setLocationRelativeTo(f);
dialog.setVisible(true);
}
};
}
static class DragGesture implements DragGestureListener {
public void dragGestureRecognized(DragGestureEvent dge) {
console.setText(console.getText() + "\ndragGesture: \t" + dge.toString());
Transferable transferable =new Transferable() {
public boolean isDataFlavorSupported(DataFlavor flavor) {
return true;
}
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{DataFlavor.stringFlavor};
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
return "transferData";
}
};
DragSourceListener sourceListener = new DragSourceAdapter() {
public void dragExit(DragSourceEvent dse) {
console.setText(console.getText() + "\ndragExit: \t" + dse.toString());
}
public void dragEnter(DragSourceDragEvent dsde) {
console.setText(console.getText() + "\ndragEnter: \t" + dsde.toString());
}
};
dge.startDrag(DragSource.DefaultCopyDrop, transferable, sourceListener);
}
}
static class DropTarget extends java.awt.dnd.DropTarget {
public DropTarget(JLabel lbl) {
super(lbl, new DropTargetAdapter() {
public void drop(DropTargetDropEvent dtde) {
try {
lbl.setText(dtde.getTransferable().getTransferData(DataFlavor.stringFlavor).toString());
} catch (Exception e) {
console.setText(e.getMessage());
}
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
}
});
}
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8184999 [macosx] Drag gestures broken when dialogs are involved
-
- Closed
-