Button bt= new Button("Button");
bt.setPrefSize(60.0, 40.0);
WritableImage image = bt.snapshot(new SnapshotParameters(), null);
try {
File f = new File("java");
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png",f);
System.out.printf("保存成功!");
} catch (IOException ex) {
System.out.printf("保存失败:" + ex.getMessage());
}
在网上找到了一段代码,改了改变成了这样。
运行成功了可是生成了一个不知道是啥东西的东西
