CLOSE PROGRAM FROM JFRAME code example
Example 1: jframe exit on close
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Example 2: 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));