Details
-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b119
-
generic
-
os_x
Description
This issue was found while working on the following JavaFX bug:
https://javafx-jira.kenai.com/browse/RT-28347
What I observe is that when a JFXPanel object acts as a drop target, dragEnter(), dragOver(), and dragExit() notifications can be sent to its DropTargetListener in a wrong order. For example:
drag enter
drag over
drag exit
drag over
or
drag enter
drag enter
To reproduce the bug, run the following JavaFX/Swing test and drag-n-drop from and to the FX scene:
JFrame f = new JFrame("F");
f.setBounds(400, 100, 320, 240);
JFXPanel p1 = new JFXPanel();
Platform.runLater(() -> {
Text t = new Text("Drag from here");
t.setStyle("-fx-font-size: 32px");
t.setOnDragDetected(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Dragboard db = t.startDragAndDrop(TransferMode.COPY);
ClipboardContent content = new ClipboardContent();
content.putString("FX TEXT");
db.setContent(content);
event.consume();
}
});
t.setOnDragDone(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
t.setText("Drag done");
}
});
Text t2 = new Text("Drop here");
t2.setStyle("-fx-font-size: 32px");
t2.setOnDragEntered(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println(event.getDragboard().getContentTypes());
event.acceptTransferModes(TransferMode.ANY);
event.consume();
}
});
t2.setOnDragOver((event) -> {
event.acceptTransferModes(TransferMode.ANY);
event.consume();
});
t2.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
t2.setText(event.getDragboard().getString());
event.setDropCompleted(true);
event.consume();
}
});
Scene s = new Scene(new FlowPane(t, t2), Color.RED);
p1.setScene(s);
});
f.add(p1);
f.setVisible(true);
If you see exceptions (or assertion errors, when run with -ea), the bug is reproduced. These exceptions are observed on Mac, but not on Windows, both before and after the fix forRT-28347.
https://javafx-jira.kenai.com/browse/RT-28347
What I observe is that when a JFXPanel object acts as a drop target, dragEnter(), dragOver(), and dragExit() notifications can be sent to its DropTargetListener in a wrong order. For example:
drag enter
drag over
drag exit
drag over
or
drag enter
drag enter
To reproduce the bug, run the following JavaFX/Swing test and drag-n-drop from and to the FX scene:
JFrame f = new JFrame("F");
f.setBounds(400, 100, 320, 240);
JFXPanel p1 = new JFXPanel();
Platform.runLater(() -> {
Text t = new Text("Drag from here");
t.setStyle("-fx-font-size: 32px");
t.setOnDragDetected(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Dragboard db = t.startDragAndDrop(TransferMode.COPY);
ClipboardContent content = new ClipboardContent();
content.putString("FX TEXT");
db.setContent(content);
event.consume();
}
});
t.setOnDragDone(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
t.setText("Drag done");
}
});
Text t2 = new Text("Drop here");
t2.setStyle("-fx-font-size: 32px");
t2.setOnDragEntered(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println(event.getDragboard().getContentTypes());
event.acceptTransferModes(TransferMode.ANY);
event.consume();
}
});
t2.setOnDragOver((event) -> {
event.acceptTransferModes(TransferMode.ANY);
event.consume();
});
t2.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
t2.setText(event.getDragboard().getString());
event.setDropCompleted(true);
event.consume();
}
});
Scene s = new Scene(new FlowPane(t, t2), Color.RED);
p1.setScene(s);
});
f.add(p1);
f.setVisible(true);
If you see exceptions (or assertion errors, when run with -ea), the bug is reproduced. These exceptions are observed on Mac, but not on Windows, both before and after the fix for