Question

I'm trying to get a snapshot of my "Java pop up window". The "Java window" looks like: http://www.directupload.net/file/d/3616/kajnpeag_png.htm

However the snapshot looks like: http://www.directupload.net/file/d/3616/cx47ga2o_png.htm

Sorry for the links, but I'm not allowed to post images yet.

So on the y-axis the autorange is missing and on the x-axis the dates are missing. Why didn't get my snapshot-function the whole picture? Do you have any suggestions/ideas how to solve this issue? For any help I would be grateful.

Code snapshot function:

public void saveAsPng(Scene scene) {
    WritableImage image = scene.snapshot(null);
    File file = new File("chart.png");
    try {
        ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
    } catch (IOException ex) {
        Logger.getLogger(Server_Application.class.getName()).log(Level.SEVERE, null, ex);
    }
}

The calling function:

@Override
public void start(Stage stage) throws Exception {
...
Parent root = FXMLLoader.load(getClass().getResource("MainPicture.fxml"));
Scene scene = new Scene(root);              
stage.setScene(scene);
stage.show();
Server_Application.serverApp.saveAsPng(scene);
...
}
Was it helpful?

Solution

I got the solution:

You have to deactivate the animation of the chart:

lineChart.setAnimated(false);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top