This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
When a JMenuBar is added to a JPanel, at the moment, it is simply added to the Other Components section in the navigator. Instead, it should be added as a regular Component and appear in the layout area of the panel. The below code demonstrates how a JMenuBar can be added to a JPanel. public class TestMenuFrame extends javax.swing.JFrame { class InnerPanel extends JPanel { InnerPanel() { setLayout(new BorderLayout()); JMenuBar menuBar = new JMenuBar(); JMenu favs = new JMenu("Menu"); menuBar.add(favs); //this line missing favs.add(new JMenuItem("Alpha")); add(menuBar, BorderLayout.NORTH); } } InnerPanel innerPanel = new InnerPanel(); /** Creates new form TestMenuFrame */ public TestMenuFrame() { initComponents(); this.getContentPane().add(innerPanel, BorderLayout.CENTER); setSize(640, 480); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code "> private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); pack(); }// </editor-fold> /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TestMenuFrame().setVisible(true); } }); } // Variables declaration - do not modify // End of variables declaration }
reassigning to form for evaluation
*** This bug has been marked as a duplicate of bug 14785 ***