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)
======================================================================