Module ij
Package ij.io

Class DragAndDropHandler

All Implemented Interfaces:
Serializable

public class DragAndDropHandler extends TransferHandler
This class handles drag&drop onto JFileChoosers.
See Also:
  • 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 drag&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).