JDK-4218517 : ctrl+mouse-press+release-crtl+drag leaves mouse unusable
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.0,1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt,windows_2000
  • CPU: x86
  • Submitted: 1999-03-09
  • Updated: 2001-05-30
  • Resolved: 2001-05-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Related Reports
Relates :  
Description

Name: vi73552			Date: 03/09/99


This demonstrates a bug in java 1.2 DnD on Windows NT.
Move the mouse pointer to a tree node, press <Ctrl>,
press left mouse button, release <Ctrl> but don't release
the mouse button, start dragging. The cursor will change
to a 'no-drop' cursor. Now release the mouse button.
The application will remain unusable (try moving or closing
the window) until you control-click.

java full version "JDK-1.2-V"
//
import java.awt.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;

import javax.swing.*;

class Bug
{
    static String expl =
    "This demonstrates a bug in java 1.2 DnD on Windows NT.\n"+
    "Move the mouse pointer to a tree node, press <Ctrl>,\n"+
    "press left mouse button, release <Ctrl> but don't release\n"+
    "the mouse button, start dragging. The cursor will change\n"+
    "to a 'no-drop' cursor. Now release the mouse button.\n"+
    "The application will remain unusable (try moving or closing\n"+
    "the window) until you control-click.";

    public static void main(String[] args)
    {
    	JFrame frame = new JFrame("Java Bug");
    	frame.getContentPane().setLayout(new FlowLayout());
    	frame.getContentPane().add(new JTextArea(expl));
    	frame.getContentPane().add(new DragTree());
    	frame.pack();
    	frame.setSize(400, 600);
    	frame.show();
    }
}
class DragTree extends JTree implements DragGestureListener, DragSourceListener, Transferable
{
    public static final DataFlavor dataFlavor = new DataFlavor(DragTree.class, "DragTree");

    DragTree()
    {
	DragSource source = DragSource.getDefaultDragSource();
        source.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
    }
    public void dropActionChanged(DragSourceDragEvent
    dsde){}
    public void dragEnter(DragSourceDragEvent dsde){}
    public void dragOver(DragSourceDragEvent dsde){}
    public void dragGestureChanged(DragSourceDragEvent dsde){}
    public void dragExit(DragSourceEvent dse){}
    public void dragDropEnd(DragSourceDropEvent dsde){}
    public void dragGestureRecognized(DragGestureEvent dge)
    {
        dge.startDrag(null, this, this);
    }
    public DataFlavor[] getTransferDataFlavors()
    {
        DataFlavor[] flavors = new DataFlavor[1];
        
        flavors[0] = dataFlavor;

        return flavors;
    }	
    public boolean isDataFlavorSupported(DataFlavor flavor)
    {
        return flavor.equals(dataFlavor);
    }
    public Object getTransferData(DataFlavor flavor)
            throws UnsupportedFlavorException, IOException
    {    
        return "aap";
    }
}
(Review ID: 55135) 
======================================================================

Name: krT82822			Date: 02/08/2000


8 Feb 2000 eval1127@eng -- reproducible on NT 4 SP 6a.  Key point in the <steps to reproduce> is that CTL must be released PRIOR to starting the drag. 

$ java -version
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)

  Bug ID 4218517 has been closed with status 'duplicate of 4269666'
However, it's a different bug which is still reproducible with JDK1.3RC1.
(with Bug 4218517 there's no real deadlock and there's a workaround.)

Here's the orignal bugreport for 4218517:
---------------------------------------------


This demonstrates a bug in java 1.2 DnD on Windows NT.
Move the mouse pointer to a tree node, press <Ctrl>,
press left mouse button, release <Ctrl> but don't release
the mouse button, start dragging. The cursor will change
to a 'no-drop' cursor. Now release the mouse button.
The application will remain unusable (try moving or closing
the window) until you control-click.

java full version "JDK-1.2-V"
//
import java.awt.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;

import javax.swing.*;

class Bug
{
    static String expl =
    "This demonstrates a bug in java 1.2 DnD on Windows NT.\n"+
    "Move the mouse pointer to a tree node, press <Ctrl>,\n"+
    "press left mouse button, release <Ctrl> but don't release\n"+
    "the mouse button, start dragging. The cursor will change\n"+
    "to a 'no-drop' cursor. Now release the mouse button.\n"+
    "The application will remain unusable (try moving or closing\n"+
    "the window) until you control-click.";

    public static void main(String[] args)
    {
    	JFrame frame = new JFrame("Java Bug");
    	frame.getContentPane().setLayout(new FlowLayout());
    	frame.getContentPane().add(new JTextArea(expl));
    	frame.getContentPane().add(new DragTree());
    	frame.pack();
    	frame.setSize(400, 600);
    	frame.show();
    }
}
class DragTree extends JTree implements DragGestureListener,
DragSourceListener, Transferable
{
    public static final DataFlavor dataFlavor = new DataFlavor
(DragTree.class, "DragTree");

    DragTree()
    {
	DragSource source = DragSource.getDefaultDragSource();
        source.createDefaultDragGestureRecognizer(this,
DnDConstants.ACTION_COPY_OR_MOVE, this);
    }
    public void dropActionChanged(DragSourceDragEvent
    dsde){}
    public void dragEnter(DragSourceDragEvent dsde){}
    public void dragOver(DragSourceDragEvent dsde){}
    public void dragGestureChanged(DragSourceDragEvent dsde){}
    public void dragExit(DragSourceEvent dse){}
    public void dragDropEnd(DragSourceDropEvent dsde){}
    public void dragGestureRecognized(DragGestureEvent dge)
    {
        dge.startDrag(null, this, this);
    }
    public DataFlavor[] getTransferDataFlavors()
    {
        DataFlavor[] flavors = new DataFlavor[1];
        
        flavors[0] = dataFlavor;

        return flavors;
    }
    public boolean isDataFlavorSupported(DataFlavor flavor)
    {
        return flavor.equals(dataFlavor);
    }
    public Object getTransferData(DataFlavor flavor)
            throws UnsupportedFlavorException, IOException
    {
        return "aap";
    }
}
(Review ID: 100961)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
14-06-2004

WORK AROUND Name: vi73552 Date: 03/09/99 press <ctrl> in combination with the left mouse button after the problem occurs. ====================================================================== Name: krT82822 Date: 02/08/2000 press <ctrl> in combination with the left mouse button after the problem occurs. (Review ID: 100961) ======================================================================
11-06-2004

SUGGESTED FIX Name: dsR10078 Date: 05/17/2001 In MSDN i was unable to find guidelines that explicitly prescribe when the drag operation should be terminated. So i used Windows Explorer as a model. Key modifiers state changes never terminate the drag operation. Additional mouse button press cancels the drag. When the drag operation is initiated with more than one button pressed the drag is cancelled on release of any button. If the drag operation is initiated with only one button pressed the drag is terminated with a drop. I suggest to implement this behavior in AwtDragSource::QueryContinueDrag(). Also i suggest to initialize m_initmods from the real modifiers state rather than from the drag trigger event modifiers, since this allows to simplify the conditions: for example if trigger event is a button press its modifiers will contain BUTTON1_MASK, but no BUTTON1_DOWN_MASK. During drag modifiers will contain both BUTTON1_MASK and BUTTON1_DOWN_MASK. Also i removed some unused variables. ###@###.### 2001-05-17 ======================================================================
17-05-2001

EVALUATION Reproduced in merlin build 25 on Windows. Not reproducible on Solaris. david.mendenhall@eng 2000-08-02 Reproducible with 12Dec2000 AWT workspace. david.mendenhall@east 2000-12-13 Name: dsR10078 Date: 05/17/2001 Currently AwtDragSource::QueryContinueDrag() is implemented so that it doesn't operate normally while the current modifiers are not a superset of the drag trigger event modifiers. If the user presses Ctrl then presses left mouse button the drag trigger event will have <Ctrl>+<Left mouse button> modifiers, if the user releases Ctrl before start dragging AwtDragSource::QueryContinueDrag() will be called when modifiers are not a superset of the drag trigger event modifiers. So AwtDragSource::QueryContinueDrag() doesn't operate normally and it doesn't terminate drag upon button release, the drag is terminated only after Ctrl+click, so that AwtDragSource::QueryContinueDrag() will be called with the modifiers equal to the modifiers of the original drag event. ###@###.### 2001-05-17 ======================================================================
17-05-2001