-
Bug
-
Resolution: Duplicate
-
P2
-
fx2.1
-
Mac OS X 10.7.3, JavaFX 2.1 beta b16, Java 1.6.0_29
Same Bug like RT-18573 ? When the following application is run under Mac OS X, DRAG_DROPPED never appears in the output. The output consists only of DRAG_OVER events:
public class DnDDemo extends Application {
/**
* @param args
* the command-line arguments
*/
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 800, 600, Color.BLACK);
stage.setScene(scene);
initSceneDragAndDrop(scene);
stage.show();
}
private void initSceneDragAndDrop(Scene scene) {
scene.setOnDragOver(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
if (db.hasFiles() || db.hasUrl()) {
event.acceptTransferModes(TransferMode.ANY);
}
System.out.println("DRAG_OVER "+db.hasFiles());
event.consume();
}
});
scene.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println("DRAG_DROPPED");
Dragboard db = event.getDragboard();
String url = null;
if (db.hasFiles()) {
url = db.getFiles().get(0).toURI().toString();
} else if (db.hasUrl()) {
url = db.getUrl();
}
event.setDropCompleted(url != null);
event.consume();
}
});
}
public class DnDDemo extends Application {
/**
* @param args
* the command-line arguments
*/
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 800, 600, Color.BLACK);
stage.setScene(scene);
initSceneDragAndDrop(scene);
stage.show();
}
private void initSceneDragAndDrop(Scene scene) {
scene.setOnDragOver(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
if (db.hasFiles() || db.hasUrl()) {
event.acceptTransferModes(TransferMode.ANY);
}
System.out.println("DRAG_OVER "+db.hasFiles());
event.consume();
}
});
scene.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println("DRAG_DROPPED");
Dragboard db = event.getDragboard();
String url = null;
if (db.hasFiles()) {
url = db.getFiles().get(0).toURI().toString();
} else if (db.hasUrl()) {
url = db.getUrl();
}
event.setDropCompleted(url != null);
event.consume();
}
});
}
- blocks
-
JDK-8117898 Mac: Drag and drop of an image from Finder does not work
-
- Closed
-
- duplicates
-
JDK-8117209 Mac: DragEvent.getDragboard().getTransferModes() returns an empty set on Mac
-
- Closed
-
- relates to
-
JDK-8119828 Mac: [DnD] mac and win has different behavior in part of transfer mode.
-
- Closed
-