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

PopupMenus do not remain showing after mouse click on Unix platforms

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 5.0
    • client-libs
    • None
    • generic
    • generic

      This bug is being filed for a problem found while investigating bug 4533641:

      "Solaris 7 also shows some problems with PopupMenus staying popped down. With 1.2.2, 1.3.1 and 1.4, clicking the right mouse button will cause the PopupMenu to appear and stay there, BUT ONLY THE FIRST TIME. Subsequent right-button clicks behave the same as on Linux - the PopupMenu appears briefly, but disappears when the mouse button is released."

      The problem is at least as bad with Solaris 9 and 1.5. Often, the PopupMenus don't even stay down the first time.

      This bug exists on all Unix platforms. Windows platforms work correctly.

      Here's my test case (based on the test case in 4533641:

      import java.awt.*;
      import java.awt.event.*;

      public class BPopupTest extends Canvas implements ActionListener, MouseListener
      {
          public static class MyPopupMenu extends PopupMenu {
              public void removeNotify() {
                  System.out.println("removeNotify");
                  super.removeNotify();
              }
          }

            MyPopupMenu menu;

            public static void main(String args[])
            {
              Frame f = new Frame();
              BPopupTest c = new BPopupTest();
              Menu submenu = new Menu("Submenu");
              MenuItem item1 = new MenuItem("This doesn't work");
              //item1.setEnabled(false);
              MenuItem item2 = new MenuItem("This works");
              MenuItem item3 = new MenuItem("Does this not work?");

              Menu subsubmenu = new Menu("SubSubMenu");
              MenuItem item4 = new MenuItem("Will this work?");

              f.add(c, BorderLayout.CENTER);
              c.menu = new MyPopupMenu();


              c.menu.add(item1);
              submenu.add(item2);
              item1.addActionListener(c);
              item2.addActionListener(c);
              item3.addActionListener(c);
              //submenu.add(item3);

              subsubmenu.add(item4);
              item4.addActionListener(c);

              submenu.add(subsubmenu);

              c.menu.add(submenu);
              c.menu.add(item3);

              c.addMouseListener(c);

              c.add(c.menu);

              //c.enableEvents(AWTEvent.MOUSE_EVENT_MASK);
              f.pack();
              f.show();
            }

          /*
            public void processMouseEvent(MouseEvent ev)
            {
              if (ev.isPopupTrigger())
                      menu.show(this, ev.getPoint().x, ev.getPoint().y);
            }
          */

            public void actionPerformed(ActionEvent ev)
            {
              System.out.println("Action Performed");
            }

            public Dimension getPreferredSize()
            {
              return new Dimension(100, 100);
            }

          public void mouseEntered(MouseEvent e) {}
          public void mouseExited(MouseEvent e) {}
          public void mousePressed(MouseEvent e) {showMenu(e);}
          public void mouseReleased(MouseEvent e) {showMenu(e);}
          public void mouseClicked(MouseEvent e) {showMenu(e);}

          private void showMenu(MouseEvent e) {
              if (e.isPopupTrigger()) {
                      menu.show(this, e.getPoint().x, e.getPoint().y);
              }
          }
      }



            yan Yuri Nesterenko
            bchristi Brent Christian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: