JMenuBar 应该在什么时候不显示

JMenuBar not showing when it should

一切似乎都正确,但菜单栏没有显示,我可能只是遗漏了一些东西。

此框架是通过简单的 new AffmView(); 从主 class 调用的。这会导致这个问题吗?

public class AffmView extends JFrame {

public AffmView() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
        Logger.getLogger(AffmView.class.getName()).log(Level.SEVERE, null, ex);
    }
     this.setSize(700, 500);
    this.setTitle("'s Factorio Mod Manager");
    this.setLocationRelativeTo(null);

    JMenuBar menubar = new JMenuBar();
    JMenu packsMenu = new JMenu("Modpacks");
    JMenuItem newPackMI = new JMenuItem("New Pack");
    packsMenu.add(newPackMI);
    menubar.add(packsMenu);
    this.setJMenuBar(menubar);

    this.rootPane.setLayout(new GridBagLayout());
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //snipped so that Whosebug wont make me write an essay, but its 
    //just some basic swing

    this.setVisible(true);
}

}

我已经确认 none 个被截断的部分导致了这个问题。

正如@FastSnail 和@camickr 在评论中提到的,问题出在 this.rootPane.

的用法上

应该改用 getContentPane()。