在 JavaFX 2.0 中将 ScatterChart 的图像复制到系统剪贴板

Fan*_*Oaf 3 clipboard image javafx-2

我需要将 JavaFX 2.0 中的 ScatterChart 复制到系统剪贴板。我不太确定如何使用盆栽点复制散点图的整个图像。

Wil*_*eed 5

不再需要任何机器人来截取屏幕截图

/**
 * Sets the image content of the clipboard to the chart supplied
 * @param chart chart you wish to copy to the clipboard
 */
public void copyChartToClipboard(ScatterChart<Double, Double> chart) {
    WritableImage image = chart.snapshot(new SnapshotParameters(), null);
    ClipboardContent cc = new ClipboardContent();
    cc.putImage(image);
    Clipboard.getSystemClipboard().setContent(cc);
}
Run Code Online (Sandbox Code Playgroud)