Copying the image of a ScatterChart to system clipboard in JavaFX 2.0

后端 未结 2 1145
感情败类
感情败类 2021-01-20 03:22

I need to copy a ScatterChart in JavaFX 2.0 to the system clipboard. I\'m not really sure how to copy the whole image of the ScatterChart with the potted points.

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-20 03:58

    Gets rid of the need for any bots to take screenshots

    /**
     * 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 chart) {
        WritableImage image = chart.snapshot(new SnapshotParameters(), null);
        ClipboardContent cc = new ClipboardContent();
        cc.putImage(image);
        Clipboard.getSystemClipboard().setContent(cc);
    }
    

提交回复
热议问题