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

Popup menu shows and hides immediately when invoked by right button click, XAWT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • client-libs
    • None
    • b47
    • generic
    • solaris
    • Verified

      Popup menu is shown and hidden immediately when invoked by right mouse button click.

      Compile and execute test below.
      Right-click on text area.
      Most likely popup menu will blink and hide.
      Left click on button.
      Popup menu is shown normally and can be navigated using mouse and keyboard.

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

      public class PopupMenuTest {

          static final Button button = new Button("Click Me");

          public static void main(String args[]) throws Exception {

              final PopupMenu popup = new PopupMenu();
              for(int i=0; i<10; i++) {
                  Menu menu = new Menu("Main Menu " + i);
                  for(int j=0; j<10; j++) {
                      MenuItem menuItem = new MenuItem("MenuItem " + j);
                      menu.add(menuItem);
                  }
                  popup.add(menu);
              }

              Frame frame = new Frame();
              frame.setLayout(new BorderLayout(5, 5));
              TextArea label = new TextArea("Text Area");
              frame.add(label);
              frame.add(button, BorderLayout.SOUTH);
              
              label.addMouseListener(new MouseAdapter() {
                  
                  public void mousePressed( MouseEvent me ) {
                      if(me.isPopupTrigger()) {
                          popup.show(me.getComponent(), me.getX(), me.getY());
                      }
                  }

                  public void mouseReleased( MouseEvent me ) {
                      if(me.isPopupTrigger()) {
                          popup.show(me.getComponent(), me.getX(), me.getY());
                      }
                  }
              });

              button.addActionListener(new ActionListener() {
                  public void actionPerformed( ActionEvent e) {
                      popup.show(button, 0, 0);
                  }
              });
              
              frame.add(popup);
              frame.setSize(200, 200);
              frame.setVisible(true);
              frame.validate();
          }
      }

      REPRODUCIBLE: OFTEN
      JDK: 6.0b42
      PLATFORM: Any XAWT
      ###@###.### 2005-07-08 15:54:48 GMT

            vbaranovsunw Vyacheslav Baranov (Inactive)
            vbaranovsunw Vyacheslav Baranov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: