title: How to Open a new JFrame window when JMenuItem is clicked
body: <p>Dear friend, I have a main application that contains a <code>Menu</code> and in each of this <code>Menu</code> there is a <code>JMenuItem</code>. I want when I click one of the <code>JMenuItem</code> I should be able to open a <code>new JFrame</code> that will do specific task. This <code>JFrame</code> should be in a different class that implements <code>ActionListener</code>, not in the same class that contains Main Method many example that I have seen in the internet and in <a href="http://stackoverflow.com">http://stackoverflow.com</a> does not give the solution in two different classes. When I try the same methods within the same class or as an inner class that implements <code>ActionListener</code> it works but not like I said 2 different classes. The reason I need it like that is because there is a lot of  <code>JMenuItems</code> in the <code>Menu</code> and each <code>JMenuItem</code> handles a great deal of process. If I am going to place everything in one file then it is not Object Oriented Programming any more and it is going to be a very very long file.  An example is shown below. However the bellow example did not work for me. Could some one point out what am I doing wrong. Thank in Advance.</p>
  
  <p>Main class that implements main method.</p>
  
  <pre><code>public class SwendaEye{
  
      public static void main(String[]args){  
      FrameandComp frame = new FrameandComp();
      JFrame win;
  
      win = frame.mainFrame();
      JMenuBar bar;
      bar = new JMenuBar();
      win.setJMenuBar(bar); 
  
      JMenu swenda = new JMenu("SWENDAEYE");// adding Swenda menu to the bar.
      bar.add(swenda);
  
                   JMenuItem open = new JMenuItem("Open");
                   swenda.add(open);
                   JMenuItem exit = new JMenuItem("Exit");
                   swenda.add(exit);
  
      JMenu tools = new JMenu("Tools");// adding Tools menu to the bar.
      bar.add(tools);
                   JMenuItem convertIP = new JMenuItem("Convert IP Address");
                   tools.add(convertIP);
                   JMenuItem convertDomain = new JMenuItem("Convert Domain Name");
                   tools.add(convertDomain);
                   convertDomain.addActionListener(new Domain());
  
        win.setVisible(true);
      }
  }
  </code></pre>
  
  <p>This is the action Listener class separate from the above class </p>
  
  <pre><code>public class Domain implements ActionListener{
  
      public void actionPerformed(ActionEvent e)
      {
          if("Convert Domain Name".equals(e.getActionCommand())){
  
              JFrame awindow = new JFrame();
              awindow.setSize(200,400);
              awindow.getContentPane().setBackground(Color.DARK_GRAY);
              awindow.setTitle("Convert");
              awindow.setDefaultCloseOperation(1);
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>In this example I am only demonstrating the Convert Domain Name <code>JMenuItem</code>.
  and before you answer please do not tell me <code>JOptionPane</code> because I basically need to do a lot of thing in this window like table, image and many more. thank again.</p>