JavaFX charts, snapshots
•
Java
I'm trying to get a snapshot of my java popup The Java window looks like:
But the snapshot looks like: http://www.directupload.net/file/d/3616/cx47ga2o_png.htm
I'm sorry for these links, but I'm not allowed to post pictures yet
Therefore, the automatic range is missing on the Y axis and the date is missing on the X axis Why not make my snapshot function global? Do you have any suggestions / ideas on how to solve this problem? I would appreciate any help
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); } }
Call 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); ... }
Solution
I got the solution:
You must deactivate the animation of the chart:
lineChart.setAnimated(false);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码