Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4199209

JMenu.removeAll() throws unexpected NullPointerException

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 12/22/98


      JMenu.removeAll() throws unexpected NullPointerException, when popupMenu is not initialized.

      See example.

      One line should be added to the code to fix this bug

      JMenu.java:713:
          public void removeAll() {
              if(popupMenu!=null) { // <--- test popupMenu is initialized
      popupMenu.removeAll();
              }
      clearListenerRegistry();
          }


      --------------- Example---------------------------
      import javax.swing.*;

      public class Test{
          public static void main(String argv[]) {
              JMenu c = new JMenu(); // Create JMenu object
              c.removeAll();

          }
      }

      ----------------output------------------
      Exception in thread "main" java.lang.NullPointerException
              at javax.swing.JMenu.removeAll(Compiled Code)
              at Test.main(Compiled Code)


      ======================================================================

            gsaab Georges Saab
            aalievsunw Artem Aliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: