本文整理汇总了Java中javafx.scene.input.Dragboard.hasUrl方法的典型用法代码示例。如果您正苦于以下问题:Java Dragboard.hasUrl方法的具体用法?Java Dragboard.hasUrl怎么用?Java Dragboard.hasUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.Dragboard
的用法示例。
在下文中一共展示了Dragboard.hasUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compositeTokenPane_DragDropped
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
void compositeTokenPane_DragDropped(DragEvent event) {
Dragboard db = event.getDragboard();
// Strangely, we get an error if we try to paste an image we put in the clipboard ourselves but File works ok?
// -Dprism.order=sw also fixes it but not sure why...
// So lets just check for File first...
if (db.hasFiles()) {
db.getFiles().forEach(file -> {
try {
updateFileNameTextField(FilenameUtils.getBaseName(file.toURI().toURL().toExternalForm()));
updatePortrait(new Image(file.toURI().toURL().toExternalForm()));
} catch (Exception e) {
log.error("Could not load image " + file, e);
}
});
event.setDropCompleted(true);
} else if (db.hasImage()) {
updatePortrait(db.getImage());
event.setDropCompleted(true);
} else if (db.hasUrl()) {
updateFileNameTextField(FileSaveUtil.searchURL(db.getUrl()));
updatePortrait(new Image(db.getUrl()));
event.setDropCompleted(true);
}
}
示例2: overlayViewFlowPane_DragDropped
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
void overlayViewFlowPane_DragDropped(DragEvent event) {
Dragboard db = event.getDragboard();
if (db.hasImage()) {
try {
// Prompt for name & return file name
File newOverlayFile = new File(currentDirectory.getCanonicalPath() + "/somefilename.png");
ImageIO.write(SwingFXUtils.fromFXImage(db.getImage(), null), "png", newOverlayFile);
} catch (IOException e) {
log.error("Error writing new overlay image.", e);
}
loadImages(overlayTreeView.getSelectionModel().getSelectedItem());
event.setDropCompleted(true);
} else if (db.hasFiles()) {
db.getFiles().forEach(file -> {
FileSaveUtil.copyFile(file, currentDirectory);
});
loadImages(overlayTreeView.getSelectionModel().getSelectedItem());
event.setDropCompleted(true);
} else if (db.hasUrl()) {
FileSaveUtil.copyFile(new File(db.getUrl()), currentDirectory);
loadImages(overlayTreeView.getSelectionModel().getSelectedItem());
event.setDropCompleted(true);
}
}
示例3: handleDragDrop
import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void handleDragDrop(DragEvent event)
{
Dragboard db = event.getDragboard();
boolean success = false;
if ( !db.hasUrl())
{
event.setDropCompleted (success);
event.consume();
return;
}
success = true;
String filePath = "";
for (File file : db.getFiles())
{
if (file.getPath().isEmpty())
continue;
filePath = file.getAbsolutePath();
if (filePath.trim().endsWith (".mp3"))
this.listener.add (filePath.trim().replace ("%20", " "));
}
}