【发布时间】:2013-12-27 19:22:34
【问题描述】:
我正在开发一个 JavaFX 应用程序。我想使用上下文菜单从应用程序中复制图像并使用 Windows 的粘贴功能将其粘贴。
File file = new File("C:\\Users\\Admin\\Desktop\\my\\mysql.gif");
Image image = new Image(file.toURI().toString());
ImageView ive =new ImageView(image);
cm = new ContextMenu();
MenuItem copy = new MenuItem("Copy");
cm.getItems().add(copy);
copy.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
//Paste Image at location
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putImage(image); // the image you want, as javafx.scene.image.Image
clipboard.setContent(content);
}
});
例如,如下图所示。
并希望通过使用 Windows 功能菜单粘贴到位置。
【问题讨论】:
标签: java javafx javafx-2 fxml javafx-8