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

popup menu grabs all input events when shown via show()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description


      michael.bundschuh@Eng 1997-01-07
      Once a popup menu is shown via show(), it captures all
      keyboard and mouse input until a mouse SELECT or MENU is generated.

      -----< begin here >-----

      import java.awt.*;
      import java.applet.*;

      /**
       * Tests the PopupMenu class
       *
       * You can run this applet with the command:
       *
       * appletviewer PopupMenuTest.java
       *
       * The following line is needed for the appletviewer to find.
       *
       * <applet code="PopupMenuTest.class" width=200 height=200> </applet>
       */
      public class PopupMenuTest extends Applet {

              PopupMenu popup;

              public void init() {

                      popup = new PopupMenu("Edit Menu");
                      popup.add("Cut");
                      popup.add("Copy");
                      popup.add("Paste");

                      add(popup);
                      resize(200, 200);

                      // Note the frame must be showing before the popup can be shown,
                      // as described in the documentation.
                      show();

                      // Bug: this grabs all input until a mouse SELECT or MENU
                      // button is pressed. This is very anti-social; I would expect
                      // the input behavior to be unimpeded. In the case this is
                      // not considered a bug, it should be documented better on how
                      // to correctly use the show() statement.
                      popup.show( this, 0, 0);
              }


              public boolean
              handleEvent( Event evt ) {
                      if ( evt.id == Event.MOUSE_DOWN ) {
                              popup.show( (Component)evt.target, evt.x, evt.y );
                              return true; // event handled
                      }
                      return super.handleEvent(evt);
              }


              public boolean
              action( Event evt, Object arg ) {

                      if ( "Cut".equals(arg) ) {
                              System.out.println("Cut");
                              return true;
                      } else if ( "Copy".equals(arg) ) {
                              System.out.println("Copy");
                              return true;
                      } else if ( "Paste".equals(arg) ) {
                              System.out.println("Paste");
                              return true;
                      }

                      return false ; // event needs to be handled
              }

      } // class PopupMenuTest

      ------< end here >------


        Attachments

          Activity

            People

            • Assignee:
              amfowler Anne Fowler (Inactive)
              Reporter:
              mbundschsunw Michael Bundschuh (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: