本文整理匯總了Java中javafx.scene.input.ClipboardContent.putImage方法的典型用法代碼示例。如果您正苦於以下問題:Java ClipboardContent.putImage方法的具體用法?Java ClipboardContent.putImage怎麽用?Java ClipboardContent.putImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.input.ClipboardContent
的用法示例。
在下文中一共展示了ClipboardContent.putImage方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handle
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
@Override
public void handle(final MouseEvent event) {
final Pane pane = (Pane) event.getSource();
final ImageView view = (ImageView) pane.getChildren().get(0);
final Dragboard db = view.startDragAndDrop(TransferMode.COPY);
final ClipboardContent content = new ClipboardContent();
content.putString(view.getId());
final ComponentPane componentPane = loadComponent(pane.getChildren().get(0).getId().toLowerCase());
workspace.getChildren().add(componentPane);
componentPane.applyCss();
final WritableImage w = componentPane.snapshot(null,null);
workspace.getChildren().remove(componentPane);
content.putImage(w);
db.setContent(content);
event.consume();
}
示例2: editCopyImageMenu_onAction
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
@FXML
void editCopyImageMenu_onAction(ActionEvent event) {
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
// for paste as file, e.g. in Windows Explorer
try {
File tempTokenFile = fileSaveUtil.getTempFileName(false, useFileNumberingCheckbox.isSelected(),
fileNameTextField.getText(), fileNameSuffixTextField);
writeTokenImage(tempTokenFile);
content.putFiles(java.util.Collections.singletonList(tempTokenFile));
tempTokenFile.deleteOnExit();
} catch (Exception e) {
log.error(e);
}
// for paste as image, e.g. in GIMP
content.putImage(tokenImageView.getImage());
// Finally, put contents on clip board
clipboard.setContent(content);
}
示例3: tokenImageView_OnDragDetected
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
@FXML
void tokenImageView_OnDragDetected(MouseEvent event) {
Dragboard db = tokenImageView.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
boolean saveAsToken = false;
try {
File tempTokenFile = fileSaveUtil.getTempFileName(saveAsToken, useFileNumberingCheckbox.isSelected(),
fileNameTextField.getText(), fileNameSuffixTextField);
writeTokenImage(tempTokenFile);
content.putFiles(java.util.Collections.singletonList(tempTokenFile));
tempTokenFile.deleteOnExit();
} catch (Exception e) {
log.error(e);
} finally {
content.putImage(tokenImageView.getImage());
db.setContent(content);
event.consume();
}
}
示例4: copyImageToClipboard
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
public void copyImageToClipboard(WritableImage image) {
ClipboardContent content = new ClipboardContent();
content.putImage(image);
Platform.runLater(() -> {
Main.clipboard.setContent(content);
Notifications.create().title("Notification").text("Image has been copied to the clipboard").showInformation();
});
}
示例5: image
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
public static ClipboardContent image(Image i) {
ClipboardContent c = new ClipboardContent();
c.putImage(i);
try {
File f = File.createTempFile("snapshot", ".png");
ImageIO.write(SwingFXUtils.fromFXImage(i, null), "png", f);
c.putFiles(Arrays.asList(f));
c.putUrl(f.toURI().toURL().toExternalForm());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return c;
}
示例6: sourceSetOnDragDetected
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
private void sourceSetOnDragDetected(ImageView source, MouseEvent e) {
Dragboard db = source.startDragAndDrop(TransferMode.COPY);
ClipboardContent content = new ClipboardContent();
Image sourceImage = source.getImage();
String imageName = getImageName(sourceImage);
content.putString(imageName);
content.putImage(source.getImage());
db.setContent(content);
e.consume();
}
示例7: prepareClipboardContent
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
private ClipboardContent prepareClipboardContent() {
ClipboardContent content = new ClipboardContent();
if (sourceFormats.contains(DataFormat.PLAIN_TEXT)) {
log("Source is putting string on dragboard");
content.putString(CONTENT_PLAIN_TEXT);
}
if (sourceFormats.contains(DataFormat.URL)) {
log("Source is putting URL on dragboard");
content.putUrl(CONTENT_URL);
}
if (sourceFormats.contains(DataFormat.IMAGE)) {
log("Source is putting image on dragboard");
content.putImage(CONTENT_IMAGE);
}
if (sourceFormats.contains(DataFormat.HTML)) {
log("Source is putting HTML on dragboard");
content.putHtml(CONTENT_HTML);
}
if (sourceFormats.contains(DataFormat.RTF)) {
log("Source is putting RTF on dragboard");
content.putRtf(CONTENT_RTF);
}
if (sourceFormats.contains(DF_CUSTOM_BYTES)) {
log("Source is putting custom four bytes on dragboard");
content.put(DF_CUSTOM_BYTES, CONTENT_CUSTOM_BYTES);
}
if (sourceFormats.contains(DF_CUSTOM_STRING)) {
log("Source is putting custom four bytes on dragboard");
content.put(DF_CUSTOM_STRING, CONTENT_CUSTOM_STRING);
}
if (sourceFormats.contains(DF_CUSTOM_CLASS)) {
log("Source is putting custom class on dragboard");
content.put(DF_CUSTOM_CLASS, CONTENT_CUSTOM_CLASS);
}
if (sourceFormats.contains(DataFormat.FILES)) {
log("Source is putting two files on dragboard");
content.putFiles(CONTENT_FILES);
}
return content;
}
示例8: exportToClipboard
import javafx.scene.input.ClipboardContent; //導入方法依賴的package包/類
public static void exportToClipboard(ChartViewer chartNode) {
final Clipboard clipboard = Clipboard.getSystemClipboard();
final ClipboardContent content = new ClipboardContent();
final int width = (int) chartNode.getWidth();
final int height = (int) chartNode.getHeight();
WritableImage img = new WritableImage(width, height);
SnapshotParameters params = new SnapshotParameters();
chartNode.snapshot(params, img);
content.putImage(img);
clipboard.setContent(content);
}