I'm making a simple application to take screenshot in intervals.so i used swing timer for this .but i have a problem when i set interval to 100 millisecond it works perfectly .

```
Timer t=new Timer(100, new ActionListener()//this is working

```

but when i set interval to 1000 it's not working. 

```
Timer t=new Timer(1000, new ActionListener()//this is not working

```

no errors but program automatically terminate.timer not fire.i use netbeans.i can see program has stop .this is what i see in the console.

![enter image description here](https://i.stack.imgur.com/RxMDy.png)

i can't figure out what have i done wrong .or have i miss something ??

this is my code

```
public class Screenshot {
    Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    private final String s;
    int i=0;
    public Screenshot() {
        SimpleDateFormat sdf=new SimpleDateFormat("M,dd,hh,mm,ss");
        s = sdf.format(new Date());
        System.out.println(s);
        shoot();
        System.out.println("CALLED");
    }

    public final void shoot() {

        Timer t=new Timer(1000, new ActionListener() {//not working with 1000 but work with 100

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    i++;
                    System.out.println(i);
                    BufferedImage capture = new Robot().createScreenCapture(screenRect);
                    ImageIO.write(capture, "jpg", new File("C:\\Users\\Madhawa.se\\Desktop\\screenshot\\"+s+"sh"+i+".jpg"));
                } catch (Exception ex) {
                   ex.printStackTrace();
                }
            }
        });
        t.start();        
    }
    public static void main(String[] args) {
        Screenshot shot=new Screenshot();       
    }    
}

```