java close jframe programmatically code example
Example 1: programatically close a jframe
// Sending a Event with the Window
// to be closed this way, will initiate
// the **closing** behaviour.
frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
Example 2: java close jframe
setVisible(false); //you can't see me!
dispose(); //Destroy the JFrame object