标签:
public class EffectTest extends Application { @Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 551, 400); scene.setOnDragOver((DragEvent event) -> { Dragboard db = event.getDragboard(); if (db.hasFiles()) { event.acceptTransferModes(TransferMode.COPY); } else { event.consume(); } }); // Dropping over surface scene.setOnDragDropped((DragEvent event) -> { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; String filePath = null; for (File file:db.getFiles()) { filePath = file.getAbsolutePath(); System.out.println(filePath); } } event.setDropCompleted(success); event.consume(); }); primaryStage.setScene(scene); primaryStage.show(); } }
标签:
原文地址:http://www.cnblogs.com/rojas/p/4721094.html