I have created a small program that is meant to take a screenshot when I click the button. It does, however, once I click it and take the screenshot and it saves as "screenshot", I can't click it and take another without overwriting the one I just took. I want it to be able to take multiple and save them all without closing the program.

[Screenshot of my code that I took with my program.](https://i.stack.imgur.com/U5w4J.png)

Thanks!

EDIT:

```
    package screenshot;

    import java.awt.AWTException;
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;

    import javax.imageio.ImageIO;

    public class NewJFrame extends javax.swing.JFrame {

public NewJFrame() {
    initComponents();
}

// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jButton1.setIcon(new javax.swing.ImageIcon("C:\\Users\\manwe\\Desktop\\java stuff\\6inch_1.png")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jButton1)
    );

    pack();
}// </editor-fold>                        

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
     try {
        Robot robot = new Robot();
        String format = "png";
        String fileName = "screenshot." + format;

        Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage screenFullImage;
        BufferedImage BufferedImage = screenFullImage = robot.createScreenCapture(screenRect);
        ImageIO.write(screenFullImage, format, new File(fileName));

    } catch (AWTException | IOException ex) {

    }
}                                        

public static void main(String args[]) {
    try {
        Robot robot = new Robot();
        String format = "png";
        String fileName = "screenshot." + format;

        Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage screenFullImage;
        BufferedImage BufferedImage = screenFullImage = robot.createScreenCapture(screenRect);
        ImageIO.write(screenFullImage, format, new File(fileName));

    } catch (AWTException | IOException ex) {

    }

    java.awt.EventQueue.invokeLater(() -> {
        new NewJFrame().setVisible(true);
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton jButton1;
// End of variables declaration                   

```

}