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

A WIn2000 popup replaces my popup menu

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      FULL PRODUCT VERSION :
      1.6.0-ea, build 1.6.0-ea-b45

      ADDITIONAL OS VERSION INFORMATION :
      win 2000 ( might be upgraded to a newer Service pack )

      A DESCRIPTION OF THE PROBLEM :
      I have 4 (uneditable ) textfields at the bottom of the window. On linux, i can click on the textfield and get a set of selectable options for that menu.
      On Win2000, when I click on the textfield, i get a system menu popup ( undo,cut,copy,paste,delete,select all ) .

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run attached program.

      click on one of the textfields.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      i expected my popup menu to show
      ACTUAL -
      a win2000 system menu showed.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * WhereIsMyPopup.java
       *
       * Created on August 10, 2005, 7:20 AM
       */

      /**
       *
       * @author gat
       */

      import java.awt.event.MouseEvent;

      public class WhereIsMyPopup extends java.awt.Frame implements java.awt.event.MouseListener {
          
          /** Creates new form WhereIsMyPopup */
          public WhereIsMyPopup() {
              initComponents();
              add( popup );
              //addMouseListener(this);
              //panel1.addMouseListener( this );
              //panel2.addMouseListener( this );
              //panel2.add( popup );
              textField1.addMouseListener( this );
              textField2.addMouseListener( this );
              //textField3.addMouseListener( this );
              //textField1.add( popup );
              //textField2.add( popup );
              //textField3.add( popup );
              //textField4.add( popup );
              //canvas1.add( differentPopup );
          }
          
          /** This method is called from within the constructor to
           * initialize the form.
           * WARNING: Do NOT modify this code. The content of this method is
           * always regenerated by the Form Editor.
           */
          private void initComponents() {
              java.awt.GridBagConstraints gridBagConstraints;

              popup = new java.awt.PopupMenu();
              menuItem1 = new java.awt.MenuItem();
              menuItem2 = new java.awt.MenuItem();
              differentPopup = new java.awt.PopupMenu();
              menuItem3 = new java.awt.MenuItem();
              menuItem4 = new java.awt.MenuItem();
              menuItem5 = new java.awt.MenuItem();
              panel1 = new java.awt.Panel();
              canvas1 = new java.awt.Canvas();
              panel2 = new java.awt.Panel();
              textField1 = new java.awt.TextField();
              textField2 = new java.awt.TextField();
              textField3 = new java.awt.TextField();
              textField4 = new java.awt.TextField();
              menuBar1 = new java.awt.MenuBar();
              menu1 = new java.awt.Menu();

              popup.setLabel("PopupMenu");
              popup.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                      popupActionPerformed(evt);
                  }
              });

              menuItem1.setLabel("Item");
              popup.add(menuItem1);

              menuItem2.setLabel("Item");
              popup.add(menuItem2);

              differentPopup.setLabel("PopupMenu");
              menuItem3.setLabel("Item");
              differentPopup.add(menuItem3);

              menuItem4.setLabel("Item");
              differentPopup.add(menuItem4);

              menuItem5.setLabel("Item");
              differentPopup.add(menuItem5);

              setLayout(new java.awt.GridBagLayout());

              addWindowListener(new java.awt.event.WindowAdapter() {
                  public void windowClosing(java.awt.event.WindowEvent evt) {
                      exitForm(evt);
                  }
              });

              canvas1.setSize(300,300);

              canvas1.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(java.awt.event.MouseEvent evt) {
                      canvas1MouseClicked(evt);
                  }
              });

              panel1.add(canvas1);

              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
              add(panel1, gridBagConstraints);

              panel2.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(java.awt.event.MouseEvent evt) {
                      panel2MouseClicked(evt);
                  }
              });

              textField1.setText("textField1");
              textField1.setEditable(false);
              panel2.add(textField1);

              textField2.setText("textField2");
              textField2.setEditable(false);
              panel2.add(textField2);

              textField3.setText("textField3");
              textField3.setEditable(false);
              textField3.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(java.awt.event.MouseEvent evt) {
                      textFieldMouseClicked(evt);
                  }
              });

              panel2.add(textField3);

              textField4.setText("textField4");
              textField4.setEditable(false);
              textField4.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(java.awt.event.MouseEvent evt) {
                      textFieldMouseClicked(evt);
                  }
              });

              panel2.add(textField4);

              add(panel2, new java.awt.GridBagConstraints());

              menu1.setLabel("Menu");
              menuBar1.add(menu1);

              setMenuBar(menuBar1);

              pack();
          }

          private void textFieldMouseClicked(java.awt.event.MouseEvent evt) {
              // TODO add your handling code here:
              showPopup( evt );
          }
          void showPopup( MouseEvent e ) {
              System.out.print("showPopup();");
              if( ( e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0
              && e.getID() == MouseEvent.MOUSE_CLICKED ) {
                  System.out.println(" popup.show();");
                  popup.show(e.getComponent(), e.getX(), e.getY() );
                  return;
               }
              System.out.println("Dont show");
              System.out.flush();
          }
          private void panel2MouseClicked(java.awt.event.MouseEvent evt) {
              // TODO add your handling code here:
              System.out.println("panel2MouseClicked. popup = " + evt.isPopupTrigger() );
          }

          private void canvas1MouseClicked(java.awt.event.MouseEvent evt) {
              // TODO add your handling code here:
              System.out.println("canvas1MouseClicked. popup = " + evt.isPopupTrigger() );
       
          }
          
          private void popupActionPerformed(java.awt.event.ActionEvent evt) {
              // TODO add your handling code here:
          }
          
          /** Exit the Application */
          private void exitForm(java.awt.event.WindowEvent evt) {
              System.exit(0);
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String args[]) {
              new WhereIsMyPopup().show();
          }
          
          //public void mouseClicked(java.awt.event.MouseEvent e) {}
          //public void mouseEntered(java.awt.event.MouseEvent e) {}
          public void mouseExited(java.awt.event.MouseEvent e) {}
          //public void mousePressed(java.awt.event.MouseEvent e) {}
          //public void mouseReleased(java.awt.event.MouseEvent e) {}
          //public void mouseExited(MouseEvent e) {
          //}

          public final void mousePressed(final MouseEvent e) {
              saySomething("Mouse button " + e.getButton() + " pressed (# of clicks: " + e.getClickCount()
              + ")", e);
              showPopup(e);
          }
          
          public final void mouseReleased(final MouseEvent e) {
              saySomething("Mouse button " + e.getButton() + " released (# of clicks: " + e.getClickCount() + ")", e);
              showPopup(e);
          }
          
          public final void mouseClicked(final MouseEvent e) {
              saySomething("Mouse button " + e.getButton() + " clicked (# of clicks: " + e.getClickCount()
              + ")", e);
              showPopup(e);
          }
          
          public final void mouseEntered(final MouseEvent e) {
          }
          
          final void saySomething(final String eventDescription, final MouseEvent e) {
              final String message = eventDescription + " detected "
              + "(isPopup=" + e.isPopupTrigger() + ")"
              + '\n';
              System.out.print(message);
              //textArea.append(message);
              //textArea.setCaretPosition(MAX_INT); //hack to scroll to bottom
          }
          // Variables declaration - do not modify
          private java.awt.Canvas canvas1;
          private java.awt.PopupMenu differentPopup;
          private java.awt.Menu menu1;
          private java.awt.MenuBar menuBar1;
          private java.awt.MenuItem menuItem1;
          private java.awt.MenuItem menuItem2;
          private java.awt.MenuItem menuItem3;
          private java.awt.MenuItem menuItem4;
          private java.awt.MenuItem menuItem5;
          private java.awt.Panel panel1;
          private java.awt.Panel panel2;
          private java.awt.PopupMenu popup;
          private java.awt.TextField textField1;
          private java.awt.TextField textField2;
          private java.awt.TextField textField3;
          private java.awt.TextField textField4;
          // End of variables declaration
          
      }

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

        Attachments

          Activity

            People

            • Assignee:
              osemenovsunw Oleg Semenov (Inactive)
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: