United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4816922 : No way to set drag icon: TransferHandler.getVisualRepresentation() is not used

Details
Type:
Bug
Submit Date:
2003-02-11
Status:
Closed
Updated Date:
2010-08-23
Project Name:
JDK
Resolved Date:
2010-08-23
Component:
client-libs
OS:
windows_xp,windows_2000
Sub-Component:
java.awt
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
1.4.0,1.4.1
Fixed Versions:
7

Related Reports
Duplicate:

Sub Tasks

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.
                                     
2012-07-23
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/
                                     
2006-06-08
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
                                     
2003-02-11



Hardware and Software, Engineered to Work Together