title: Same menu opened in two different JFrames works only on the last one
body: <p>I'm trying to write a simple Paint application in which the user will be able to open new <code>JFrames</code> (in new Threads) with Drawing Panels, and each of those frames will have a <code>JMenuBar</code> on top, however, only the last open frame has a functional menu bar, all the remaining (open) frames show menu but the menu doesn't work (nothing happens when I click). Does anyone know how to fix this?</p>
  
  <p>I've simplified the code to leave only the sections regarding <code>JMenuBar</code>.</p>
  
  <p>The code consists of the following classes:</p>
  
  <p>Main.java</p>
  
  <pre><code>package sample;
  
  public class Main {
  
      Main() {
  
          MainFrameThread.getMainFrameThread().run();
  
      }//end of Main()
  
      public static void main(String[] args) {
          new Main();
      }
  
  }//end of Main class
  </code></pre>
  
  <p>TopMenu.java</p>
  
  <pre><code>package sample;
  
  import javax.swing.*;
  
  public class TopMenu extends JMenuBar {
  
      private JMenu menu_File;
      private static JMenuItem menu_New;
  
      public static JMenuItem getMenu_New() {
          return menu_New;
      }
  
      public TopMenu() {
  
          menu_File = new JMenu("File");
          menu_New = new JMenuItem("New");
          this.add(menu_File);
          menu_File.add(menu_New);
  
      }//end of TopMenu()
  
  }//end of TopMenu extends JMenuBar
  </code></pre>
  
  <p>MainFrameThread.java</p>
  
  <pre><code>package sample;
  
  public class MainFrameThread extends Thread {
  
      private static MainFrameThread mainFrameThread = new MainFrameThread();
  
      public static MainFrameThread getMainFrameThread() {
          return mainFrameThread;
      }
  
      public MainFrameThread() {}
  
      @Override
      public void run() {
  
          MainFrame mainFrame = new MainFrame();
  
      }//end of public void run()
  
  }//end of public class FrameSizeDialogThread
  </code></pre>
  
  <p>ActionController.java</p>
  
  <pre><code>package sample;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  public class ActionController {
  
      private static ActionController actionController = new ActionController();
      private ListenForMenu listenForMenu = new ListenForMenu();
  
      public static ActionController getActionController() {
          return actionController;
      }
  
      public ActionController() {}
  
      public void clickOnMenu(TopMenu topMenu) {
          TopMenu.getMenu_New().addActionListener(listenForMenu);
      }
  
      //listener for menu
      public class ListenForMenu implements ActionListener {
          public void actionPerformed(ActionEvent ev) {
  
              if(ev.getSource() == TopMenu.getMenu_New()) {
                  MainFrame newMainFrame = new MainFrame();
              }//end of if(ev.getSource() == TopMenu.getMenu_New())
  
          }//end of public void actionPerformed(ActionEvent ev)
      }//end of public class ListenForMenu
  
  }//end of ActionController class
  </code></pre>
  
  <p>and MainFrame.java</p>
  
  <pre><code>package sample;
  
  import javax.swing.*;
  import java.awt.*;
  
  public class MainFrame extends JFrame {
  
      public MainFrame() {
  
          JFrame frame = new JFrame("Paint Application");
  
          //creating menu
          TopMenu topMenu = new TopMenu();
          ActionController.getActionController().clickOnMenu(topMenu);
          frame.setJMenuBar(topMenu);
  
          //frame properties
          frame.setSize(800, 600);
          frame.setResizable(true);
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
  
      }//end of public MainFrame()
  
  }//end of public class MainFrame
  </code></pre>
  
  <p>I'm stuck, nothing works, regardless where I initialise the MainFrame.java. Does anyone see the mistake???</p>