我正在编写一个3D绘图软件,在Java中遇到了一个问题。 在代码的某个部分它是工作正常的:
try {
ImageIcon savePane=new ImageIcon("save.png");
String FilePath= (String)JOptionPane.showInputDialog(null,"Enter file path and name\n Warning: Instead of one '\\' write '\\\\'", "Save",JOptionPane.PLAIN_MESSAGE,savePane,null,"C:\\\\example.png");
BufferedImage image = new Robot().createScreenCapture(new Rectangle(110,130,put.getWidth()-3,put.getHeight()));
ImageIO.write(image, "png", new File(FilePath));
System.out.println(FilePath);
} catch (IOException e) {
e.printStackTrace();
} catch (HeadlessException e) {
e.printStackTrace();
} catch (AWTException e) {
e.printStackTrace();
}
而在另一个中,它却没有起作用:
try {
String UndoFolder= "was.png";
BufferedImage image = new Robot().createScreenCapture(new Rectangle(110,130,put.getWidth()-3,put.getHeight()));
ImageIO.write(image, ".png",new File(UndoFolder));
} catch (IOException e1) {
e1.printStackTrace();
} catch (AWTException e1) {
e1.printStackTrace();
} catch (HeadlessException e3) {
e3.printStackTrace();
}
你能告诉我如何使它工作吗?谢谢。 在你问之前,是的,它会执行代码的那一部分,我检查过了。
编辑:
哦,现在工作正常了,谢谢。