title: Jumping from one GUI window to another GUI
body: <p>I'm working on a java application which has 5 gui windows, one of them is greeting or main window, I've finished my work on all logical parts and I'm 99.99% done, the only thing left is that how can i code in this way that when i click on a button , let say a button on main window , and it will lead me to the 2nd window and the main window will be automatically closed, How can i make it happen?</p>
  
  <p>Any help would be appreciated. </p>
  
  <hr>
  
  <p><strong>Edit</strong>  </p>
  
  <p>here is the code sir</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  import java.util.*;
  
  class Nc extends JFrame
  {
  private JLabel label;
  private JLabel label1;
  private JLabel label2;
  private JLabel label3;
  private JLabel label4;
  private JButton b;
  private JButton o;
  private JButton h;
  private JButton d;
  
  private Bn ob;
  private Hd oh;
  private Oc oo;
  private Dc od;
  
  public Nc()
  {
      setTitle("Number Converter");
      setSize(200 , 300);
      setResizable(false);
      setLocation(500 , 200);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLayout(new FlowLayout(FlowLayout.CENTER, 25, 10));
  
      label = new JLabel("Number Converter");
      label1 = new JLabel("Java Application");
      label2 = new JLabel("Programmed by: Hassan Zia");
      label3 = new JLabel("Copyright 2014");
      label4 = new JLabel("Click a button");
  
      b = new JButton("Binary");
      o = new JButton("Octal");
      h = new JButton("Hexa Decimal");
      d = new JButton("Decimal");
  
      add(label);
      add(label1);
      add(label2);
      add(label3);
      add(label4);
  
      add(b); // Binary Button
      add(o); // Octal Button
      add(h); // Hexa Decimal Button
      add(d); // Decimal Button
  
      b.addActionListener(new action());
      o.addActionListener(new action());
      h.addActionListener(new action());
      d.addActionListener(new action());
  
      setVisible(true);
  }
  
  void bnc()
  {
      ob = new Bn();
  }
  
  void hdc()
  {
      oh = new Hd();
  }
  
  void occ()
  {
      oo = new Oc();
  }
  
  void dcc()
  {
      od = new Dc();
  }
  
  private class action implements ActionListener
  {
      public void actionPerformed(ActionEvent e)
      {
          if (e.getSource() == b)
          {
              bnc();
          }
          if (e.getSource() == h)
          {
              hdc();
          }
          if (e.getSource() == o)
          {
              occ();
          }
          if (e.getSource() == d)
          {
              dcc();
          }
      }
  }
  
  public static void main (String args[])
  {
      Nc obj = new Nc();
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/0bL43.png" alt="This is a picture of the app"></p>