JDK-4816922 : No way to set drag icon: TransferHandler.getVisualRepresentation() is not used
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2003-02-11
  • Updated: 2010-08-23
  • Resolved: 2010-08-23
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.
JDK 7
7Resolved
Related Reports
Duplicate :  
Description
Name: jk109818			Date: 02/11/2003


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

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195] SP3

ADDITIONAL OPERATING SYSTEMS :
Linux as well


A DESCRIPTION OF THE PROBLEM :
For Drag and Drop via the TransferHandler Mechanism,
The docs state, it should be possible to supply a visual
representation of the dragged items in a subclass of
javax.swing.TransferHandler by overriding the method
public Icon getVisualRepresentation(Transferable t)

This has no effect. Looking at the source of
javax.swing.TransferHandler, it is obvious, that
the internal class javax.swing.TransferHandler.DragHandler
never uses this. Insetead, it initiates the drag with a
null-Image.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. get my example from
http://hh.bonn.iz-soz.de/fetch/TransferHandlerBugs.java
2. compile, run, open the tree and select something
3. drag that something around

EXPECTED VERSUS ACTUAL BEHAVIOR :
while dragging, the platforms Tree-Leaf Icon should
accompany the mouse cursor as an iconic representation of
the dragged items.

Instead, i only get the (move/copy/link - dependig on
modifiers) mouse cursor - or on linux the default white block.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
http://hh.bonn.iz-soz.de/fetch/TransferHandlerBugs.java
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
rewriting almost the complete TransferHandler since all
of the relevant methods/members are private and can not be
overriden...
if only the internal classes like SwingTransferHandler were
not private and could be instanciated by a derived
TransferHandler...
(Review ID: 180034) 
======================================================================

Comments
SUGGESTED FIX For historical context, adding patch submitted to OpenJDK bugzilla for posterity.
23-07-2012

EVALUATION We made a very strong effort to include fixing this as part of our Swing Drag and Drop enhancements in Mustang. Unfortunately, there still is not a complete solution available. Although it appears as simple as changing TransferHandler to call getVisualRepresentation() and pass it to the AWT subsystem, that wouldn't be good enough; AWT hasn't implemented drag image support on key systems (ie. Windows). During investigation of how to provide this support, it was discovered that there doesn't *appear* to be a proper Windows API for implementing this. While it is true that Windows applications like IE and Explorer support drag images, notice that the images stop working when you drag into any other application. Swing and AWT are searching for a solution that will work across the entire desktop. This may mean looking deeper for a proper API, or inventing something to take care of it. This feature is being proposed as an AWT feature for Dolphin, with Swing a strong backer of the proposal. For now, one can implement drag images themselves within their own application, by using the glasspane. I demonstrated this at JavaOne 2006, and intend to post the code shortly. Please keep an eye on my blog: http://weblogs.java.net/blog/shan_man/
08-06-2006

EVALUATION Yes, I agree that this method does not currently work. I have also noticed that it has never been implemented. Making this work correctly would offer a nice DnD feature. Would like to investigate for Tiger. ###@###.### 2003-02-11
11-02-2003