I have another solution, although you have to add the JMenuBar in the "Other Components" in NetBeans (good enough). Create a JPanel and then add another JPanel inside (call it child) that fills the entire outter JPanel. Place your controls in the child panel. Then add the JMenuBar but NetBeans will place it in the "Other Components". Edit your source and in the ctor after it calls "initComponents" place a call to this function:
public static void setJPanelMenuBar(JPanel parent, JPanel child, JMenuBar menuBar) {
parent.removeAll();
parent.setLayout(new BorderLayout());
JRootPane root = new JRootPane();
parent.add(root, BorderLayout.CENTER);
root.setJMenuBar(menuBar);
root.getContentPane().add(child);
parent.putClientProperty("root", root); //if you need later
}
For example, your ctor might look like this:
public MyPanel() {
initComponents();
setJPanelMenuBar(this, child, myMenuBar);
}
Works for me. Got the idea by looking at JInternalFrame source code. All it does is replace the child JPanel with a JRootPane() and then put the child into the root pane s content pane.