Name: jl125535 Date: 07/31/2003
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
FULL OPERATING SYSTEM VERSION : Red Hat Linux 7.2, glibc-
2.2.4-13, kernel=2.4.7-10
A DESCRIPTION OF THE PROBLEM :
When dragging a file or group of files from a Gnome
directory browser window, the DnD Transferables contain
empty DataFlavor arrays and will not coerce their payload
into any flavor at all.
On Windows, same vm version, the Transferable supports
DataFlavor.javaFileListFlavor. I would expect the Linux
version to do the same.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the given test case.
2.Drag a file from Gnome into the drop target.
3.Drop it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: The drop method is given a Transferable with
DataFlavor of type DataFlavor.javaFileList.
Actual: The drop method is given a Transferable with no
DataFlavors at all.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages/exceptions.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
/**
* Displays a window that can accept drops. It then displays the flavors
* supported by the drop, and if one of the flavors is
DataFlavor.javaFileListFlavor,
* iterates the list and displays it's contents.
*
* On Windows, dragging files into the window shows the flavors as expected.
On
* Linux (Red Hat 7.2, Gnome), however, the flavor array is empty.
*/
public class DNDList extends JList
implements DropTargetListener
{
DropTarget dropTarget = null;
public DNDList()
{
dropTarget = new DropTarget(this, this);
}
public void dragEnter(DropTargetDragEvent event)
{
event.acceptDrag(DnDConstants.ACTION_MOVE);
}
public void dragExit(DropTargetEvent event)
{}
public void dragOver(DropTargetDragEvent event)
{}
public void drop(DropTargetDropEvent event)
{
Transferable transferable = event.getTransferable();
DefaultListModel model = new DefaultListModel();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
event.acceptDrop(DnDConstants.ACTION_MOVE);
if (flavors.length == 0)
model.addElement("Drop contains no flavors!");
else
for (int i = 0; i < flavors.length; i++)
model.addElement(flavors[i]);
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
{
try
{
List files = (List) transferable.getTransferData
(DataFlavor.javaFileListFlavor);
Iterator i = files.iterator();
while (i.hasNext())
model.addElement(" " + i.next().toString());
}
catch (UnsupportedFlavorException e)
{
System.out.println(e.getMessage());
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
setModel(model);
}
public void dropActionChanged(DropTargetDragEvent event)
{}
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.getContentPane().add(new DNDList());
frame.setSize(400, 200);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
No workaround.
(Incident Review ID: 164756)
======================================================================