private void createAndShowGUI(){
  frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  frame.setVisible(true);
}

private void createAndShowGUI ( ) { frame . setDefaultCloseOperation ( JFrame . DO_NOTHING_ON_CLOSE ) ; frame . setVisible ( true ) ; }
create the gui and show it . for thread safety , this method should be invoked from the event - dispatching thread .
