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

REGRESSION: MousePressed and MouseReleased events not being sent to modal dialog

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.1
    • client-libs
    • x86
    • windows_nt



      Name: gm110360 Date: 11/12/2001


      java version "1.3.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
      Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

      I found this problem when I wanted to verify the text in a field once the field
      loses focus. If the text was invalid then I would bring up a modal dialog with
      an OK and Help button. I found that if the field loses focus by way of a mouse
      click then the modal dialog does not respond to mouse clicks, the buttons do
      nothing, but it does respond to the space bar. If the field loses focus by
      pressing the tab key then the modal dialog responds to the mouse.This is only
      occuring on Windows platforms, could not reproduce on Soalris.

      In my test program, I can see that the button is getting mouseEntered and
      mouseClicked events, but not mousePressed or mouseReleased when the problem
      occurs. This program will create a frame with two text fields. When focus
      leaves the first one, a modal dialog with a button appears. First use tab to
      change focus between fields to bring up the modal dialog and verify you can use
      the mouse to click on the button and dismiss the dialog. Next, use the mouse to
      click in the fields to bring up the dialog. Now the dialog should not be
      responding to mouse clicks until you click some where on the desktop, so that
      the dialog loses focus.

      Test Program:
      import java.awt.*;
      import java.awt.event.*;

      public class ModalBug extends Frame
                             implements FocusListener,
                                        MouseListener,
                                        WindowListener
      {

          TextField bugField1;
          TextField bugField2;
          Panel bugPanel;
          Button bugButton;
          Dialog bugDialog;

          public void windowOpened(WindowEvent e){}
          public void windowClosed(WindowEvent e){}
          public void windowIconified(WindowEvent e){}
          public void windowDeiconified(WindowEvent e){}
          public void windowDeactivated(WindowEvent e){}
          public void windowActivated (WindowEvent e){}
          public void windowClosing (WindowEvent e)
          {
              System.out.println("window closing");
              Window tmp = (Window)e.getSource();
              tmp.dispose();
          }

          public void mouseClicked(MouseEvent e){System.out.println("mouse clicked");}
          public void mousePressed(MouseEvent e){System.out.println("mouse pressed");}
          public void mouseReleased(MouseEvent e)
          {
              System.out.println("mouse released");
              bugDialog.dispose();
          }
          public void mouseEntered(MouseEvent e) {System.out.println("mouse
      entered");}
          public void mouseExited(MouseEvent e){System.out.println("mouse exited");}

          public void focusGained(FocusEvent e){}
          public void focusLost(FocusEvent e)
          {
              bugDialog = new Dialog(this, true);
              bugButton = new Button();
              bugButton.addMouseListener(this);
              bugDialog.add(bugButton);
              bugDialog.setSize(50,50);
              bugDialog.addWindowListener(this);

              Point oldLoc = bugDialog.getLocation();
              if (oldLoc.x == 0 && oldLoc.y == 0)
              {
                  Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                  Dimension size = bugDialog.getSize();

                  int x = (screen.width - size.width)/2;
                  if (x < 0)
                     x = 0;
                  int y = (screen.height - size.height)/2;
                  if (y < 0)
                     y = 0;

                  bugDialog.setLocation(x, y);
              }
              bugDialog.setVisible (true);
          }


          public ModalBug()
          {
              super();
              bugPanel = new Panel();
              bugField1 = new TextField();
              bugField1.addFocusListener(this);
              bugField2 = new TextField();
              bugPanel.add(bugField1);
              bugPanel.add(bugField2);
              this.add(bugPanel);
              this.setSize(100,100);
              this.addWindowListener(this);

              Point oldLoc = getLocation();
              if (oldLoc.x == 0 && oldLoc.y == 0)
              {
                  Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                  Dimension size = this.getSize();

                  int x = (screen.width - size.width)/2;
                  if (x < 0)
                     x = 0;
                  int y = (screen.height - size.height)/2;
                  if (y < 0)
                     y = 0;

                  setLocation(x, y);
              }
              this.setVisible(true);
          }
          public static void main(String args[])
          {
              ModalBug myTest = new ModalBug();
          }
      }

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

      (Review ID: 134792)
      ======================================================================

            son Oleg Sukhodolsky (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: