Pane root = new WebViewPane();
Scene scene = new Scene(root, 1280, 900);
scene.setOnDragOver(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
if (db.hasFiles()) {
event.acceptTransferModes(TransferMode.COPY);
} else {
event.consume();
}
}
});
// Dropping over surface
scene.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles()) {
success = true;
String filePath;
for (File file:db.getFiles()) {
filePath = file.getAbsolutePath();
locationField.setText(filePath);
}
}
event.setDropCompleted(success);