Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageIO.write not working?

I'm writing a 3D paint and I found a problem in java. In one part of the code it's working:

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();
} 

While in another one it isn't working:

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();
}

Can you tell me how to make it work? Thanks Before you ask, yes it does execute that part of the code, I checked.

Edit:

Ohhh working fine now thanks

like image 538
Nemanja Neca Stojanovic Avatar asked Jul 10 '13 19:07

Nemanja Neca Stojanovic


1 Answers

ImageIO.write(image, "png",new File(UndoFolder));

Instead of:

ImageIO.write(image, ".png",new File(UndoFolder));
like image 142
Mohammad Changani Avatar answered Sep 18 '22 05:09

Mohammad Changani