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

mouseDragged event still fired while drag and drop

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: boT120536 Date: 04/22/2001


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

      Hi all!

      Here's my problem.
      I have a component (a JList, but I don't think it depends on the component)
      that has both a MouseMotionListener and a dragGestureRecognizer (don't ask me
      why, I simply need to do that).
      During the beginning of a drag and drop (not a simple mouseDragged event), the
      normal behaviour is to get a few mouseDragged events, until the gesture
      recognizer fires the drag and drop.
      The fact is that when you drag and drop very quickly (leaving the component
      very early with the mouse, before the drag and drop begins), the mouseDragged
      events are continuously fired even after the drag and drop has begun/end!

        To demonstrate the problem, I have taken the drag and drop list example at this
      address:
      http://java.sun.com/docs/books/tutorial/dnd/sheetal.html
      and modified the code of the DNDList constructor a bit :
        public DNDList() {

      dropTarget = new DropTarget (this, this);
      dragSource = new DragSource();
      dragSource.createDefaultDragGestureRecognizer( this,
      DnDConstants.ACTION_MOVE, this);
      // Here's the mouse motion listener
      MouseMotionListener mouseMotionListener = new MouseMotionAdapter()
      {
      public void mouseDragged(MouseEvent e)
      {
      System.out.println(e.getPoint());
      }
      };
      addMouseMotionListener(mouseMotionListener);
      }

      As you can see, I simply added the mouse motion listener on the list.

      Here is a normal output for a drag and drop :

      java.awt.Point[x=89,y=6]
      java.awt.Point[x=90,y=7]
      java.awt.Point[x=91,y=7]
      java.awt.Point[x=93,y=8]
      1.dragGestureRecognized(dge)
      java.awt.Point[x=96,y=8]
      1. dragEnter(target)
      1. dragOver(target)
      1.dragEnter(source)
      1. dragOver(target)
      1.dragExit(source)
      1. dragExit(target)
      1.dragExit(source)
      2. dragEnter(target)
      2. dragOver(target)
      1.dragEnter(source)
      2. dragOver(target)
      1.dragExit(source)
      1.dragExit(source)
      2. dragExit(target)
      2. drop(DropTargetDropEvent)
      1.dragExit(source)
      1.dragDropEnd(dsde)

      Now, if you drag from a location that is not very far from the bounds of the
      list and you quickly drag outside of the list, then complete your drag and drop
      operation, here's the output :
      java.awt.Point[x=81,y=8]
      java.awt.Point[x=82,y=8]
      java.awt.Point[x=85,y=6]
      1.dragGestureRecognized(dge)
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      2. dragEnter(target)
      2. dragOver(target)
      1.dragEnter(source)
      2. dragOver(target)
      1.dragExit(source)
      java.awt.Point[x=89,y=-10]
      2. dragOver(target)
      1.dragExit(source)
      2. dragOver(target)
      1.dragExit(source)
      java.awt.Point[x=89,y=-10]
      2. dragOver(target)
      1.dragExit(source)
      2. dragOver(target)
      1.dragExit(source)
      2. dragExit(target)
      2. drop(DropTargetDropEvent)
      java.awt.Point[x=89,y=-10]
      1.dragExit(source)
      1.dragDropEnd(dsde)
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]
      java.awt.Point[x=89,y=-10]

      As you can see, the mouseDragged events are still fired even after the drop at
      the same location (when the mouse was "lost" by the DND component).
      I have reproduced this bug on many platforms (windows/jdk1.2.2, windows/jdk1.3,
      linux/jdk1.3, Solaris/jdk1.2, AIX/jdk1.3).
      You can download the complete source+classes for evaluating this bug as a zip
      at:
      http://jytou.free.fr/dndsun.zip
      (Review ID: 120921)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                agerasimsunw Alexander Gerasimov (Inactive)
                Reporter:
                bonealsunw Bret O'neal (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: