@FXML void dragDropped(DragEvent event) { /* data dropped */ /* if there is a string data on dragboard, read it and use it */ Dragboard db = event.getDragboard(); boolean success = false; if (db.hasUrl()) { imageView.setImage(new LocatedImage(db.getUrl())); success = true; } /* let the source know whether the string was successfully * transferred and used */ event.setDropCompleted(success); event.consume(); }
@FXML public void webViewDragDropped(DragEvent event) { Dragboard db = event.getDragboard(); boolean dropCompleted = false; if (db.hasFiles()) { File draggedFile = db.getFiles().get(0); if (draggedFile.getName().toLowerCase().endsWith(".html")) { try { URL url = new URL("file", "", draggedFile.getAbsolutePath()); loadContent(url); dropCompleted = true; } catch (MalformedURLException ex) { } } } event.setDropCompleted(dropCompleted); }