setVisible(false); //you can't see me! dispose(); //Destroy the JFrame object
frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));