Results 1 to 9 of 9
  1. #1
    anix is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default empty menuItem in the menu

    Hello,

    I use netbeans 6.8,
    when I put a menuItem that I called Examen, it is not shown in the menu (it is shown but without text)
    NB: the code of menus is in blue then we could not change it
    also, other menuItem are good (their text are shown in the execution)
    thank you for your response
    Last edited by anix; 06-08-2010 at 11:41 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    anix is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    The code is in blue color then we could not change it
    the problem is with Examen and RechRDV

    Java Code:
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
    
            mainPanel = new javax.swing.JPanel();
            menuBar = new javax.swing.JMenuBar();
            javax.swing.JMenu fileMenu = new javax.swing.JMenu();
            jMenuItem1 = new javax.swing.JMenuItem();
            recherchePatient = new javax.swing.JMenuItem();
            RDV = new javax.swing.JMenuItem();
            rechRDV = new javax.swing.JMenuItem();
            Examen = new javax.swing.JMenuItem();
            javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
            javax.swing.JMenu helpMenu = new javax.swing.JMenu();
            javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
            statusPanel = new javax.swing.JPanel();
            javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
            statusMessageLabel = new javax.swing.JLabel();
            statusAnimationLabel = new javax.swing.JLabel();
            progressBar = new javax.swing.JProgressBar();
            jTextField1 = new javax.swing.JTextField();
    
            mainPanel.setName("mainPanel"); // NOI18N
    
            javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
            mainPanel.setLayout(mainPanelLayout);
            mainPanelLayout.setHorizontalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 429, Short.MAX_VALUE)
            );
            mainPanelLayout.setVerticalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 177, Short.MAX_VALUE)
            );
    
            menuBar.setName("menuBar"); // NOI18N
    
            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ris1.Ris1App.class).getContext().getResourceMap(Ris1View.class);
            fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
            fileMenu.setName("fileMenu"); // NOI18N
    
            jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
            jMenuItem1.setName("jMenuItem1"); // NOI18N
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem1ActionPerformed(evt);
                }
            });
            fileMenu.add(jMenuItem1);
    
            recherchePatient.setText(resourceMap.getString("recherchePatient.text")); // NOI18N
            recherchePatient.setName("recherchePatient"); // NOI18N
            recherchePatient.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    recherchePatientActionPerformed(evt);
                }
            });
            fileMenu.add(recherchePatient);
    
            RDV.setText(resourceMap.getString("RDV.text")); // NOI18N
            RDV.setName("RDV"); // NOI18N
            RDV.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    RDVActionPerformed(evt);
                }
            });
            fileMenu.add(RDV);
    
            rechRDV.setText(resourceMap.getString("rechRDV.text")); // NOI18N
            rechRDV.setName("rechRDV"); // NOI18N
            rechRDV.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rechRDVActionPerformed(evt);
                }
            });
            fileMenu.add(rechRDV);
    
            Examen.setText(resourceMap.getString("Examen.text")); // NOI18N
            Examen.setName("Examen"); // NOI18N
            Examen.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExamenActionPerformed(evt);
                }
            });
            fileMenu.add(Examen);
    
            javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(ris1.Ris1App.class).getContext().getActionMap(Ris1View.class, this);
            exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
            exitMenuItem.setName("exitMenuItem"); // NOI18N
            exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    exitMenuItemActionPerformed(evt);
                }
            });
            fileMenu.add(exitMenuItem);
    
            menuBar.add(fileMenu);
    
            helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
            helpMenu.setName("helpMenu"); // NOI18N
    
            aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
            aboutMenuItem.setName("aboutMenuItem"); // NOI18N
            helpMenu.add(aboutMenuItem);
    
            menuBar.add(helpMenu);
    
            statusPanel.setName("statusPanel"); // NOI18N
    
            statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
    
            statusMessageLabel.setName("statusMessageLabel"); // NOI18N
    
            statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
    
            progressBar.setName("progressBar"); // NOI18N
    
            javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
            statusPanel.setLayout(statusPanelLayout);
            statusPanelLayout.setHorizontalGroup(
                statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(statusMessageLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 243, Short.MAX_VALUE)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(statusAnimationLabel)
                    .addContainerGap())
            );
            statusPanelLayout.setVerticalGroup(
                statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(statusMessageLabel)
                        .addComponent(statusAnimationLabel)
                        .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(3, 3, 3))
            );
    
            jTextField1.setName("jTextField1"); // NOI18N
    
            setComponent(mainPanel);
            setMenuBar(menuBar);
            setStatusBar(statusPanel);
        }// </editor-fold>
    Moderator Edit: Code tags added
    Last edited by Fubarable; 06-08-2010 at 05:48 PM. Reason: Moderator Edit: Code tags added

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    I've added code tags to allow your code to be more easily read, but yet even with the tags, it's almost impossible to tell what your problem as you still have lots of netbeans code clogging up your post. Can you create a small Swing app without using NetBeans, by doing it by hand? If so, do so, create a small JMenuBar and JMenu, and try to reproduce your error.

    Also, have you gone through the Sun Swing tutorial on how to create menus with Swing? If not, you'd better do so so you understand what's going on here. You can find it here: How to Use Menus (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Also, are you sure that your resource bundle resourceMap has a String that maps to "Examen.text"?

  6. #6
    anix is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    I thank you for your reply
    I am not sure that my resource has a String that maps to "Examen.text"

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by anix View Post
    I am not sure that my resource has a String that maps to "Examen.text"
    You would do well to investigate this.

  8. #8
    anix is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    I fixed the problem,
    I have copied the function initComponents() into another one initComponents1
    where I don't use Examen.setText(resourceMap.getString("Examen.text" ));
    but simply Examen.setText("Examen");
    it works very well now
    thank you for your post

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by anix View Post
    I fixed the problem,
    I have copied the function initComponents() into another one initComponents1
    where I don't use Examen.setText(resourceMap.getString("Examen.text" ));
    but simply Examen.setText("Examen");
    it works very well now
    thank you for your post
    You're welcome. A possible problem here though is that by doing it this way your GUI loses its ability to be locale responsive. But if this isn't important, then no big deal.

Similar Threads

  1. Replies: 3
    Last Post: 10-27-2009, 02:19 PM
  2. various actions in menuitem of popupmenu
    By Peggy in forum Java Applets
    Replies: 0
    Last Post: 12-11-2008, 11:50 AM
  3. MenuItem
    By Sarinam in forum New To Java
    Replies: 1
    Last Post: 07-15-2008, 10:30 AM
  4. Replies: 7
    Last Post: 05-09-2008, 07:54 AM
  5. presse 1 menuitem execute 4 times the same JFrame
    By marcvb in forum New To Java
    Replies: 0
    Last Post: 12-27-2007, 09:48 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •