static void closeOnEscape(final JFrame frame){
  closeOnEscape(frame,frame.getRootPane());
}

static void closeOnEscape ( final JFrame frame ) { closeOnEscape ( frame , frame . getRootPane ( ) ) ; }
make the window close when the used presses escape . the event will be the same as when the user closes the window using the window manager .
