public void closeAfter2sec()
    {
        Thread t = new Thread(new Runnable() {
            
                public void run() {
                    try {
                        Thread.sleep(3000);
                        
                        setVisible(false);
                    } catch(InterruptedException e) {
                        setVisible(false);
                    }
                }
        });
        t.start();
    }