Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 75292 - Incorrect code generated when JMenuBar added to JPanel
Incorrect code generated when JMenuBar added to JPanel
Status: RESOLVED DUPLICATE of bug 14785
Product: guibuilder
Classification: Unclassified
Component: Code
5.x
All Windows XP
: P3 (vote)
: TBD
Assigned To: issues@guibuilder
issues@guibuilder
sp_review_61
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-20 16:06 UTC by kitfox
Modified: 2012-09-11 16:06 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments

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
    {
        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
    
}
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 ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo