JMenuBar を使用して JFrame を作成する際に問題があります。ここに MenuBarBuilder クラスがあります。
public class MenuBuilder extends JMenuBar
{
  private Model model;
  public MenuBuilder(Model model)
  {
    this.model = model;
    buildMenuBar();
  }
  public void buildMenuBar()
  {
    JMenu menuFile = new JMenu("File");
    JMenu menuEdit = new JMenu("Edit");
    JMenu menuHelp = new JMenu("Help");
    menuHelp.setMnemonic('H');
    menuFile.setMnemonic('F');
    menuEdit.setMnemonic('E');
    JMenuItem menuItemExit = new JMenuItem("Exit");
    menuItemExit.setAccelerator(model.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
    menuItemExit.setAction(new ActionExit(model));
    menuFile.add(menuItemExit);
    add(menuFile);
    add(menuEdit);
    add(menuHelp);
  }
}
JFrame は別のクラスで作成されます。
public MainGUI(boolean loadConfig, String loadConfigDir, Model model)
  {
    try
    {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e)
    {
      GlobalVariables.LOGGING_logger.error("Something went wrong while getting the Look and Feel of current Windows Version for Userinterface", e);
    }
    try
    {
      this.model = model;
      frameMain = new JFrame("MainFrame");
      frameMain.setJMenuBar(new MenuBuilder(model));
      frameMain.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
      frameMain.addWindowListener(this);
      frameMain.setMinimumSize(new Dimension(500, 500));
      frameMain.pack();
      frameMain.setSize(800, 800);
      frameMain.setLocationRelativeTo(null);
      frameMain.setVisible(true);
    }
    catch (Exception e)
    {
      GlobalVariables.LOGGING_logger.error("Error while seeting up the main GUI.", e);
      MessagesToUser.errorMessageBothFilesIssue(true);
    }
  }
を表示した後JFrame、すべての MenuItems は空ですが、存在し、機能 ( ActionExit) も正しく機能しています。JMenuItem次のコードで新しいを設定するmenuFile.add(new JMenuItem("Exit"));と、期待どおりに機能し、JFrame には正しいJMenuBar. なぜこうなった???
編集: プログラムを終了するだけの ActionExit クラスは次のとおりです。
public class ActionExit extends AbstractAction
{
  private Model model;
  public ActionExit(Model model)
  {
    this.model = model;
  }
  @Override
  public void actionPerformed(ActionEvent e)
  {
    System.exit(0);
  }
}