JDK-5043688 : DropTargetDragEvent.acceptDrag(int) doesn't work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-05-07
  • Updated: 2006-08-31
  • Resolved: 2006-08-31
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Name: rmT116609			Date: 05/06/2004


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

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
DropTargetDragEvent.acceptDrag(DnDConstants.ACTION_COPY) doesn't work
This line doesn't achieve anything.

By holding down ctrl the copy icon appears, however the above line should make the copy icon appear without having to hold down ctrl.
Leaving out the above line in the code makes no difference to the outcome.
Users are lead to believe they can't drop, when in fact they can drop by copying.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run code
highlight and drag text

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the icon to look like the copy icon
ACTUAL -
the icon looks like the can't drop icon

REPRODUCIBILITY :
This bug can be reproduced always.

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

public class Test {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    JTextField text = new JTextField("Drag Me");
    text.setDragEnabled(true);
    try {
      text.getDropTarget().addDropTargetListener(new DropTargetAdapter() {
        public void dragOver(DropTargetDragEvent dtde) {
          dtde.acceptDrag(DnDConstants.ACTION_COPY);
        }

        public void drop(DropTargetDropEvent dtde) {
        }
      });
    }
    catch (TooManyListenersException ex) {
      System.out.println("Error.... " + ex);
    }
    frame.getContentPane().add(text);
    frame.setSize(500, 500);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}
---------- END SOURCE ----------
(Incident Review ID: 225126) 
======================================================================

Comments
EVALUATION Fixed by 4869264.
31-08-2006

EVALUATION Name: agR10216 Date: 05/07/2004 The test case given in the description mixes Swing DnD support and direct AWT DnD support. Usage of direct AWT DnD support with Swing components is discouraged. (Swing registers its own drag/drop listeners that control DnD operations, and none should directly interfere with them.) This is not a bug, as well as those ones that mentioned in the section "see also" and have a common problem: usage of direct AWT DnD support with Swing components. Employ Swing DnD support (javax.swing.TransferHandler, etc.) for Swing components. ###@###.### 2004-05-07 ====================================================================== The submitter provided a pure AWT test case that reveals the same problem as 4869264 (drag & drop action negotiation does not honor the targets supported actions); refer to its evaluation. So this issue will be fixed along with 4869264. ###@###.### 2004-08-17
17-08-2004