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

No sub PopupMenu in PopupMenu (1.1.x only, win32 only)

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_95, windows_nt

      Description



      Name: rlT66838 Date: 07/17/97


      -1- Exact steps to reproduce the problem

      java text file : Test.java

      open a frame with popup menu (containing a sub popup menu)
      which is triggered by isPopupTrigger ()

      compile : javac Test.java
      run : java Test.java

      This source code works perfectly under Solaris 2.5.1 and IRIX 6.3 but not under Windows 95.
      This 'bug' has been fixed quite recently (since 1.1.2 for Solaris) so it may be in the process
      for other platforms such as Windows 95 (hope so!)

      -2- Java SOURCE CODE
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      import java.awt.*;
      import java.awt.event.*;

      public class Test extends Frame implements MouseListener {
        public final PopupMenu popupMenu = new PopupMenu ("Editer");
        public final MenuItem itemCut = new MenuItem ("Couper");
        public final MenuItem itemCopy = new MenuItem ("Copier");
        public final MenuItem itemPaste = new MenuItem ("Coller");
        public final MenuItem itemPasteChild = new MenuItem ("Coller fils");
        public final PopupMenu popupFind = new PopupMenu ("Chercher");
        public final MenuItem itemFind = new MenuItem ("Nouveau");
        public final MenuItem itemAgain = new MenuItem ("Rechercher");

        public static void main (String arg []) {
          Test test = new Test ();

          test.setVisible (true);
        }
        public Test () {
          super ("Test");

          defaultPopup ();

          add (popupMenu);
          addMouseListener (this);

          pack ();
        }
        public void defaultPopup () {
          popupMenu.removeAll ();
          popupMenu.add (itemCut);
          popupMenu.add (itemCopy);
          popupMenu.add (itemPaste);
          popupMenu.add (itemPasteChild);

          popupFind.removeAll ();
          popupFind.add (itemFind);
          popupFind.add (itemAgain);

          // ^^^^^^ HERE IS THE WIN95 BUGGY SECTION ^^^^^^

          popupMenu.add (popupFind); // comment this line and it will not crash, but not show the
                                     // sub popup menu as well (works all right under Solaris & IRIX)

          // ^^^^^^^^^^^ END OF BUGGY SECTION ^^^^^^^^^^^^
        }

        public Dimension getPreferredSize () {
          return new Dimension (400, 400);
        }
        public Dimension getMinimumSize () {
          return getPreferredSize ();
        }
        // MouseListener
        public void mouseClicked (MouseEvent e) {
          if (e.isPopupTrigger ())
            System.out.println ("isPopupTrigger 1");
        }
        public void mousePressed (MouseEvent e) {
          if (e.isPopupTrigger ())
            popupMenu.show (this, e.getX (), e.getY ());
        }
        public void mouseReleased (MouseEvent e) {
          if (e.isPopupTrigger ())
            popupMenu.show (this, e.getX (), e.getY ());
        }
        public void mouseEntered (MouseEvent e) {
        }
        public void mouseExited (MouseEvent e) {
        }
      }
      ^^^^^^^^^^^^^^^^^ end of source code ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      -3- Exact text of any error message(s) that appeared.

      java.lang.IllegalArgumentException: illegal popup menu container class
              at sun.awt.windows.WPopupMenuPeer.<init>(WPopupMenuPeer.java:45)
              at sun.awt.windows.WToolkit.createPopupMenu(WToolkit.java:229)
              at java.awt.PopupMenu.addNotify(PopupMenu.java:68)
              at java.awt.PopupMenu.addNotify(PopupMenu.java:74)
              at java.awt.Component.addNotify(Component.java:2102)
              at java.awt.Container.addNotify(Container.java:1012)
              at java.awt.Window.addNotify(Window.java:101)
              at java.awt.Frame.addNotify(Frame.java:145)
              at java.awt.Window.pack(Window.java:113)
              at Test.<init>(Test.java:27)
              at Test.main(Test.java:15)

      -4- Any trace information
          cf. -3-

      -5- Include additional configuration information
          apparently a platform dependent error (Win95 vs. Solaris & Irix)


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

        Attachments

          Activity

            People

            • Assignee:
              ibdsunw Ibd Ibd (Inactive)
              Reporter:
              rlewis Roger Lewis (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: