JavaFX 2.2 and above provides a convenient snapshot feature. It takes a snapshot of any node or scene.
The following method saves the barChart node as a png image:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Note: You could test this code with our AddressApp example (see download at the end of AddressApp Tutorial Part VII). Just add the saveAsPng() method to the BirthdayStatisticsController class and call the method through some action (e.g. a new button).