title: Destroy instance of class then create instance of it again
body: <p>i have a class (Class ButtonX) that contains a button</p>
  
  <p>when user clicks the button, it will create instance of the class <code>DialogX</code></p>
  
  <p>when I create instance of the class <code>DialogX</code> it will show up <code>JDialog</code></p>
  
  <pre><code>  public class ButtonX {
  
      public ButtonX() {
          JFrame me = new JFrame();
          JButton n = new JButton("show dialog");
          n.addActionListener(ListenerX.listen);
          me.getContentPane().add(n);
          me.pack();
          me.setVisible(true);
      }
  
      public static void main (String[]args){
          new ButtonX();
      }
  }
  </code></pre>
  
  <p>listener of that <code>JButton</code></p>
  
  <pre><code>    public class ListenerX {
      public static ActionListener listen = new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              DialogX dialogx = null;
              dialogx = new DialogX();
          }};
  }
  </code></pre>
  
  <p>class that contains <code>JDialog</code></p>
  
  <pre><code> public class DialogX {
      static JDialog g = new JDialog();
      public DialogX() {
          JLabel label = new JLabel("label");
          g.getContentPane().setLayout(new FlowLayout());
          g.getContentPane().add(label);
          g.pack();
          g.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
          g.setVisible(true);
      }
  
  }
  </code></pre>
  
  <p>what I try to achieve is, that when user clicks the button, it will destroy instance of class <code>DialogX</code> ( if it exist ) and then create again instance of <code>DialogX</code></p>
  
  <p>What to do?</p>
  
  <p>thanks..</p>
  
  <p>forgive my english..</p>