JDK-4069431 : bogus mousePressed event when dragging mouse out of Canvas - NT
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.3,1.1.4
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1,windows_95,windows_nt
  • CPU: other,x86
  • Submitted: 1997-08-04
  • Updated: 1998-03-12
  • Resolved: 1998-03-12
Related Reports
Duplicate :  
Description
Compile and run the included applet.  Drag select the text and move the mouse
out of the text area.  Look at the output printed to the screen, and notice
that the Canvas which displays the text receives a mousePressed event the
first time you leave the text area.

The canvas is watching for mouse enter, exit, press, release, and drag.  The
extra mouse pressed event screws up the scrolling behavior.  It shouldn't
be generated, and isn't generated on Solaris.
================================================================================
daniel.indrigo@Canada 1997-09-05 Here is another example showing the problem and possibly another related problem.

Run this code on windowsNT Workstation 4.0
I ran it on HP Vectra 166 MHz.

Press mouse button on the Canvas and drag it so that mouse exits
the Frame. Watch the output. 
1 - You will see MousePressed event right after MouseExit. This should not happen - mouse button
has not been released yet! 
2 - Now release the mouse button while outside of the Frame and move mouse  into the Frame.
You will get two MouseReleased events separated by mouseEnter!!!
This also should not be happening. 
3 - If you release the mouse button after moving it back into the Frame
area, you will get only one MouseReleased event!

NOTE: This works fine on Solaris 2.5.
Something is seriously wrong here!!!!

import java.awt.*;
import java.awt.event.*;
 
public class MyFrame extends Frame 
{
        class Comp  extends Canvas implements MouseListener, MouseMotionListener {
 
            public Comp() {
                super();
                                addMouseListener(this);
                                addMouseMotionListener(this);
            }
 
            public Dimension getPreferredSize()
            {
                return new Dimension(400,400);
            }
public void mousePressed(MouseEvent event)
{
System.out.println("Mouse Pressed");
}
public void mouseDragged(MouseEvent event)
{
System.out.println("Mouse Dragged");
}
public void mouseReleased(MouseEvent event)
{
System.out.println("Mouse Released");
}
public void mouseMoved(MouseEvent event) {
System.out.println("Mouse moved");
                        }
                        public void mouseEntered(MouseEvent e) {
                                System.out.println("Mouse entered");
                        }
                        public void mouseExited(MouseEvent e) {
                                System.out.println("Mouse exited");
                        }
                        public void mouseClicked(MouseEvent e) {
                                System.out.println("Mouse clicked");
                        }
    };
 
        public  MyFrame() {
                super();
                add("Center",new Comp());
        }
 
        public static void main(String [] args) {
                MyFrame f = new MyFrame();
                f.pack();
                f.setVisible(true);
        }
}

company - AT&T , email - ###@###.###
=============================================================================
[another user]

joon.oh@Eng 1997-11-03



When disposing a popup window inside of mousePressed() of that popup
causing same mousePressed() to be passed to the underlying window
which was covered by the popup.
(all windows are Java windows).

Here is a very simple example. Compile it, run it on NT (I haven't
tested on 95).
You'll see a frame covered with the red-colored popup window. 
Click on a popup anywhere where it covers the frame. 
You'll see println() coming from the frame's mousePressed().
It is a very strong bug. 100% reproducible.
After the popup is hidden you can press CTRL+click inside the
frame to bring it back. Move the mouse anywhere outside of the popup,
move it inside the popup and click again.
It is the case with all 1.1.2, 1.1.3 and 1.1.4.

Regards,
=Kirill Khazanovsky
TIBCO Software Inc.



(650) 846-5219
###@###.###

//
//---------------------------------------------------------------------
// This is an example of an extra mousePressed() event being delivered
// to a window which was covered by a popup window (instance of Window).
// Every time popup is up on the screen and completely or partially
covering
// any other (Java) windows on the screen it happens.
// With many popup-type windows they need to be deleted upon a click
// inside of them (menu, combobox, etc.) which make this problem very
// important.
//---------------------------------------------------------------------

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

class MyPopup extends Window implements WindowListener, MouseListener {

    public MyPopup(PopupProblem parent) {
        super(parent);
    	addMouseListener(this);
    	setBackground(Color.red);
    }

    public void paint(Graphics g) {
        g.setColor(Color.black);
        g.drawRect(0,0,getSize().width-1,getSize().height-1);
        int h = g.getFontMetrics().getHeight();
        g.drawString("I am not a part of frame.",20,40);
        g.drawString("I am a popup.",20,40+h);
        g.drawString("  Click on me in order to see",20,40+2*h);
        g.drawString("  mousePressed() coming into the
frame",20,40+3*h);
    }

 	public void mousePressed(MouseEvent evt) {
 	    // when we have a mouse click hide it here
 	    // which is always what all the popups want
 	    // (like popup menus, comboboxes, etc.)
 	    hide();
 	}

 	public void mouseClicked(MouseEvent evt){}
 	public void mouseEntered(MouseEvent evt){}
 	public void mouseExited(MouseEvent evt){}
 	public void mouseReleased(MouseEvent evt){}
 	public void windowClosing(WindowEvent evt){}
 	public void windowActivated(WindowEvent evt){}
 	public void windowClosed(WindowEvent evt){}
 	public void windowDeactivated(WindowEvent evt){}
 	public void windowDeiconified(WindowEvent evt){}
 	public void windowIconified(WindowEvent evt){}
 	public void windowOpened(WindowEvent evt){}
}

//================= main Frame ===================================

public class PopupProblem extends Frame
             implements WindowListener, MouseListener {

    MyPopup thePopup=null;

    public PopupProblem() {
    	super("PopupProblem window");
    	addMouseListener(this);
    	addWindowListener(this);
	    setLayout(null);
    	setBounds(50,50,380,280);
    	setVisible(true);

    	thePopup = new MyPopup(this);
    	Rectangle myrect = getBounds();
    	myrect.grow(-10,-20);
    	thePopup.setBounds(myrect);
    	thePopup.setVisible(true);
    }

    public static void main(String args[]) {
    	new PopupProblem();
    }

 	public void mousePressed(MouseEvent evt) {
 	    System.out.println("mousePressed in the main Frame at
"+evt.getX()+","+evt.getY()+", modifiers="+evt.getModifiers());

 	    if ( (evt.getModifiers() & InputEvent.CTRL_MASK) != 0 ) {
 	        // after we re-show it it still happens always
                // if after popup shown you move the mouse out and back
in
 	        thePopup.setVisible(true);
 	    }
	}

 	public void windowClosing(WindowEvent evt) {
 	    dispose();
 	    System.exit(1);
 	}
 	public void mouseClicked(MouseEvent evt){}
 	public void mouseEntered(MouseEvent evt){}
 	public void mouseExited(MouseEvent evt){}
 	public void mouseReleased(MouseEvent evt){}
 	public void windowActivated(WindowEvent evt){}
 	public void windowClosed(WindowEvent evt){}
 	public void windowDeactivated(WindowEvent evt){}
 	public void windowDeiconified(WindowEvent evt){}
 	public void windowIconified(WindowEvent evt){}
 	public void windowOpened(WindowEvent evt){}
}

//************************ end *************************

Comments
PUBLIC COMMENTS Extra mousePressed event from Canvas component the first time the mouse is dragged out of the Canvas.
10-06-2004