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

1.4.0 REGRESSION: Action/Mouse event was lost after right-click popup menu

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.1
    • client-libs



      Name: rmT116609 Date: 09/19/2002


      FULL PRODUCT VERSION :
      java version "1.4.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
      Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


      FULL OPERATING SYSTEM VERSION :

      Windows 98 [Version 4.10.2222]

      A DESCRIPTION OF THE PROBLEM :
      Click inside a text field. Then right click to pop up some
      menu. Select an item. Then click on a button. The last
      click will not work. User has to click again for the
      button's action perform to kick in.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.Run the attached app
      2.Left-Click on the the button "Me" for sanity check (click
      OK after)
      3.Left-click in the text field (make sure to see cursor
      blinking)
      4. Right-click in the text field to pop up a menu
      5. Select an item
      6. Left-click on the button "Me" (no pop up)
      7. Left-click on the button "Me" again - pop up.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      A click on a button must generate an actionperformed no matter where you were before that.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.event.*;
      import java.awt.*;

      public class PopupSwallLowClick extends javax.swing.JFrame {
          
          /** Creates new form PopupSwallLowClick */
          public PopupSwallLowClick() {
              initComponents();
          }
          
          /** 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() {
              jButton1 = new javax.swing.JButton();
              jTextField1 = new javax.swing.JTextField();
              jLabel1 = new javax.swing.JLabel();
              jLabel2 = new javax.swing.JLabel();
              jLabel3 = new javax.swing.JLabel();
              jLabel4 = new javax.swing.JLabel();

              getContentPane().setLayout(null);

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

              jButton1.setText("Me");
              jButton1.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                      jButton1ActionPerformed(evt);
                  }
              });

              getContentPane().add(jButton1);
              jButton1.setBounds(120, 50, 51, 26);

              jTextField1.setText("TextField");
              jTextField1.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(java.awt.event.MouseEvent evt) {
                      jTextField1MouseClicked(evt);
                  }
              });

              getContentPane().add(jTextField1);
              jTextField1.setBounds(110, 190, 200, 20);

              jLabel1.setText("3)Right click text field");
              getContentPane().add(jLabel1);
              jLabel1.setBounds(110, 220, 150, 16);

              jLabel2.setText("1) Click on Me");
              getContentPane().add(jLabel2);
              jLabel2.setBounds(120, 30, 90, 16);

              jLabel3.setText("4) Click Me again");
              getContentPane().add(jLabel3);
              jLabel3.setBounds(120, 80, 120, 16);

              jLabel4.setText("2) Click in the textfield");
              getContentPane().add(jLabel4);
              jLabel4.setBounds(110, 170, 160, 16);

              pack();
              java.awt.Dimension screenSize =
      java.awt.Toolkit.getDefaultToolkit().getScreenSize();
              setSize(new java.awt.Dimension(382, 302));
              setLocation((screenSize.width-382)/2,(screenSize.height-302)/2);
          }

          private void jTextField1MouseClicked(java.awt.event.MouseEvent evt) {
              // Add your handling code here:
              if((evt.getModifiers() & MouseEvent.BUTTON3_MASK) == 0) return;
              //JOptionPane.showMessageDialog(this, "Right clicked");
              
              JPopupMenu menu = new JPopupMenu();
            //tfTransConInVar.setText("");
            menu.add(new MyPanel(menu));
            
            menu.show(this.jTextField1, evt.getX(),evt.getY());

          }

          private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
              // Add your handling code here:
              JOptionPane.showMessageDialog(this,"Yes you did click me.");
          }
          
          /** 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 PopupSwallLowClick().show();
          }
          
          
          // Variables declaration - do not modify
          private javax.swing.JLabel jLabel4;
          private javax.swing.JLabel jLabel1;
          private javax.swing.JLabel jLabel3;
          private javax.swing.JLabel jLabel2;
          private javax.swing.JButton jButton1;
          private javax.swing.JTextField jTextField1;
          // End of variables declaration
          
      }


      class MyPanel extends JPanel{
          JPopupMenu menu = null;
          public MyPanel(JPopupMenu menu){
              this.setLayout(new BorderLayout());
              JList list = new javax.swing.JList();
              list.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mousePressed(java.awt.event.MouseEvent evt) {
                      listMousePressed(evt);
                  }
              });
              this.add(list, BorderLayout.CENTER);
              DefaultListModel listModel = new DefaultListModel();
              listModel.addElement("Item 1");
              listModel.addElement("Item 2");
              list.setModel(listModel);
              this.setPreferredSize(new Dimension(100, 200));
              this.menu = menu;
          }
          
          private void listMousePressed(java.awt.event.MouseEvent evt) {
              menu.setVisible(false);
        }
          
          
      }


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

      Release Regression From : 1.3.1_04
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 164746)
      ======================================================================

            duke J. Duke
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: