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

Popup menu disappears without waiting for interaction

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      Present on Mustang beta 2 -
      jre-6-beta2-bin-b83-windows-i586-04_may_2006

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Service Pack 2

      A DESCRIPTION OF THE PROBLEM :
      We have an applet embedded in, but not fully occupying, an HTML page.
      We have a mouse event handler on an item in the page that calls a method on the applet to activate a pop-up menu outside the bounds of the applet, over some of the text in the page. The first time this handler operates on a mouse click, the menu appears briefly and then disappears.

      In our simple example, subsequent clicks operate correctly. In our actual application, the menus always disappear. We have been unable to isolate that behaviour, but hope this may provide enough of a clue.

      The problem is present in all 1.5 versions. We have tested it against Mustang beta 2 because it is similar to 6345002 which is apparently fixed there.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See description - test case supplied.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Popup menu should appear, and accept interaction.
      ACTUAL -
      First time, the popup menu appears and then disappears.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // The HTML source

      <html>
      <head>
      <title>PopupTest</title>
      </head>
      <body>
      <h1>Steps To Reproduce</h1>
      <ul>
      <li onmousedown="PopupTest.handleClick(200,-150)">Click on <strong>this text</strong> to reveal the popup menu.</li>
      </ul>

      <h1>Expected</h1>
      <p>Popup menu shows and waits for the user to click on a different item.</p>

      <h1>Actual</h1>
      <p>Popup menu shows and immediately disappears, preventing the user from selecting an item.</p>

      <applet name="PopupTest" codebase="." code="TestApplet" width="200" height="100">
      </applet>
      </body>
      </html>

      // The Java source

      import javax.swing.*;

      public class TestApplet extends JApplet
      {
      boolean visible = false;
          JPopupMenu menu = new JPopupMenu();

          public void init() {
           menu.add("Item 1");
           menu.add("Item 2");
              getContentPane().add(menu);
          }

          public void handleClick(int x, int y)
          {
      System.out.println("handleClick - visible ? " + visible);
           if (visible)
           {
           menu.setVisible(false);
           visible = false;
           }
           else
           {
           menu.show(this,x,y);
           visible = true;
           }
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      After the menu has appeared and disappeared, it is possible to retrieve it by means of the Windows Menu key.

        Attachments

          Activity

            People

            Assignee:
            alexp Alexander Potochkin (Inactive)
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: