title: How to close current JFrame?
body: <p>I have read similar topics but i did find answer there.</p>
  
  <p>I created <code>JFrame</code> with close button. After click I want to close current window. I try <code>setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE)</code>, or <code>setVisible(false)</code>.</p>
  
  <pre><code>public class Windows {
   JFrame frame;
   JFrame frame1;
  
  
  public Windows(){
  
  } 
  
  
   public JFrame getCreateFrame(){
  
    frame1 = new JFrame("Create User");
    frame1.setSize(500,500);
    frame1.setVisible(true);
    frame1.getContentPane().add(new Panels().getwelcomTxtLabelPanel1(), BorderLayout.NORTH);
    frame1.getContentPane().add(new Panels().getCreateUser(), BorderLayout.SOUTH); 
    frame1.getContentPane().add(new Panels().getUserLabel(), BorderLayout.WEST);
    frame1.getContentPane().add(new Panels().getUserField(), BorderLayout.CENTER);
    return frame1;
       }
    }
  </code></pre>
  
  <p>Here is a button.</p>
  
  <pre><code>public JButton getCancelButton(){
  
   cancel = new JButton("cancel");
   cancel.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e){
            new Windows().getCreateFrame().setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
  
                }
           });
  return cancel;
       }
  </code></pre>