java.lang.Object
javax.swing.TransferHandler
ij.io.DragAndDropHandler
- All Implemented Interfaces:
java.io.Serializable
public class DragAndDropHandler
extends javax.swing.TransferHandler
This class handles drag&drop onto JFileChoosers.
- See Also:
- Serialized Form
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DragAndDropHandler(javax.swing.JFileChooser jFileChooser)
Given a JFileChooser 'fc', this is how to use this class: -
Method Summary
Modifier and Type Method Description boolean
canImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] transferFlavors)
Returns whether any of the transfer flavors is supportedboolean
importData(javax.swing.JComponent comp, java.awt.datatransfer.Transferable t)
Imports the drag&drop file or list of files and sets the JFileChooser to this.boolean
isSupportedTransferFlavor(java.awt.datatransfer.DataFlavor flavor)
Returns whether this transfer flavor is supported.
-
Constructor Details
-
DragAndDropHandler
public DragAndDropHandler(javax.swing.JFileChooser jFileChooser)Given a JFileChooser 'fc', this is how to use this class:fc.setDragEnabled(true); fc.setTransferHandler(new DragAndDropHandler(fc));
-
-
Method Details
-
canImport
public boolean canImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] transferFlavors)Returns whether any of the transfer flavors is supported- Overrides:
canImport
in classjavax.swing.TransferHandler
-
importData
public boolean importData(javax.swing.JComponent comp, java.awt.datatransfer.Transferable t)Imports the drag&drop file or list of files and sets the JFileChooser to this. Returns true if successful- Overrides:
importData
in classjavax.swing.TransferHandler
-
isSupportedTransferFlavor
public boolean isSupportedTransferFlavor(java.awt.datatransfer.DataFlavor flavor)Returns whether this transfer flavor is supported. We support File Lists and Strings (plain or as list of URLs).
-