JDK-4874232 : Cannot initiate drag and drop from within an unselected JInternalFrame
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-06-04
  • Updated: 2005-08-22
  • Resolved: 2005-08-22
Related Reports
Duplicate :  
Description
Name: rmT116609			Date: 06/04/2003


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


FULL OS VERSION :
Windows 2000 [Version 5.00.2195] and Windows XP (SP1)

A DESCRIPTION OF THE PROBLEM :
If you attempt to drag from an unselected JInternalFrame then the operation is ignored. Instead, you have to click twice - once to select the frame and a second time to begin the drag operation.

Other bug reports have raised similar problems with other 'draggable' widgets, such as scroll bars, and some of these claim to have been fixed. However, as noted elsewhere, the fixes seem to be a little tactical, rather than addressing the underlying problem.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached simple program and try to drag from an unselected frame.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Dragging should begin on the first click - a second click should be unnecessary.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.datatransfer.StringSelection;
import java.awt.dnd.*;

public class DragBug extends JFrame implements DragGestureListener, DragSourceListener {

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

    DragBug() {
        super("DragBug - cannot drag from unselected internal frame");
        setBounds(100, 100, 500, 250);

        JDesktopPane desktop = new JDesktopPane();
        desktop.setBounds(0, 0, 400, 150);
        getContentPane().add(desktop);

        desktop.add(new DragInternalFrame("one", 100, 50, this));
        desktop.add(new DragInternalFrame("two", 250, 50, this));

        setContentPane(desktop);
        setVisible(true);
    }

    private class DragInternalFrame extends JInternalFrame {

        public DragInternalFrame(String title, int x, int y, DragGestureListener dgl) {
            setBounds(x, y, 100, 100);
            setTitle(title);

            JLabel p = new JLabel("Drag-Me");
            DragSource dragsource = new DragSource();
            dragsource.createDefaultDragGestureRecognizer(p, DnDConstants.ACTION_COPY, dgl);
            getContentPane().add(p);
            setVisible(true);
        }
    }

    public void dragGestureRecognized(DragGestureEvent dge) {
        System.out.println("dragGestureRecognized");
        dge.startDrag(DragSource.DefaultCopyDrop, new StringSelection("dummy"), this);
    }

    public void dragDropEnd(DragSourceDropEvent dsde) {
    }

    public void dragEnter(DragSourceDragEvent dsde) {
    }

    public void dragExit(DragSourceEvent dse) {
    }

    public void dragOver(DragSourceDragEvent dsde) {
    }

    public void dropActionChanged(DragSourceDragEvent dsde) {
    }
}

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

CUSTOMER SUBMITTED WORKAROUND :
You have to click twice 
(Review ID: 187010) 
======================================================================

Comments
EVALUATION This was reproducible in 1.6.0-ea-b45, which was the build before the integration of the fix for 4398733 MouseClicked event not delivered when switched between 2 Internal frames Not reproducible in 1.6.0-ea-b46. Duplicate of 4398733 MouseClicked event not delivered when switched between 2 Internal frames
22-08-2005

EVALUATION Name: agR10216 Date: 06/09/2003 This bug seems similar to the Swing bug 4521075 (Drag gesture in JAVA different from Windows). Recategorizing to classes_swing. ###@###.### 2003-06-09 ====================================================================== This reason for this bug is described in bug 4662254. Our event forwarding mechanism fixes a number of these problems, but it seems that it may not be the case for this situation. More investigation is needed. ###@###.### 2003-06-16
16-06-2003