Module ij
Package ij.io

# Class DragAndDropHandler

java.lang.Object
javax.swing.TransferHandler
ij.io.DragAndDropHandler

All Implemented Interfaces:
  `Serializable`

public class DragAndDropHandler extends TransferHandler
This class handles draginvalid input: '&drop' onto JFileChoosers.

See Also:
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from class javax.swing.TransferHandler

`TransferHandler.DropLocation, TransferHandler.TransferSupport`

## Field Summary

### Fields inherited from class javax.swing.TransferHandler

`COPY, COPY_OR_MOVE, LINK, MOVE, NONE`

## Constructor Summary

Constructors
Constructor
Description
`DragAndDropHandler(JFileChooser jFileChooser)`
Given a JFileChooser 'fc', this is how to use this class:

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canImport(JComponent comp, DataFlavor[] transferFlavors)`
Returns whether any of the transfer flavors is supported
`boolean`
`importData(JComponent comp, Transferable t)`
Imports the draginvalid input: '&drop' file or list of files and sets the JFileChooser to this.
`boolean`
`isSupportedTransferFlavor(DataFlavor flavor)`
Returns whether this transfer flavor is supported.

### Methods inherited from class javax.swing.TransferHandler

`canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, getSourceActions, getVisualRepresentation, importData, setDragImage, setDragImageOffset`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DragAndDropHandler

public DragAndDropHandler(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(JComponent comp, DataFlavor[] transferFlavors)
Returns whether any of the transfer flavors is supported

Overrides:
  `canImport` in class `TransferHandler`

### importData

public boolean importData(JComponent comp, Transferable t)
Imports the draginvalid input: '&drop' file or list of files and sets the JFileChooser to this. Returns true if successful

Overrides:
  `importData` in class `TransferHandler`

### isSupportedTransferFlavor

public boolean isSupportedTransferFlavor(DataFlavor flavor)
Returns whether this transfer flavor is supported. We support File Lists and Strings (plain or as list of URLs).