本文整理匯總了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", " "));
}
}