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.

Bug 75292 - Incorrect code generated when JMenuBar added to JPanel
Summary: Incorrect code generated when JMenuBar added to JPanel
Status: RESOLVED DUPLICATE of bug 14785
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All Windows XP
: P3 blocker (vote)
Assignee: issues@guibuilder
Depends on:
Reported: 2006-04-20 16:06 UTC by kitfox
Modified: 2012-09-11 16:06 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description kitfox 2006-04-20 16:06:45 UTC
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
            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()
        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()

    }// </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
Comment 1 Jiri Prox 2006-04-24 12:12:02 UTC
reassigning to form for evaluation
Comment 2 Tomas Pavek 2012-09-11 16:06:30 UTC

*** This bug has been marked as a duplicate of bug 14785 ***