Class FileTransferHandler

java.lang.Object
javax.swing.TransferHandler
noaa.coastwatch.gui.FileTransferHandler
All Implemented Interfaces:
Serializable

public class FileTransferHandler extends TransferHandler
The FileTransferHandler class is used with the JComponent.setTransferHandler() method to handle one or more java.io.File objects during a drag and drop operation. The user must specify a Runnable to call when drag and drop of file information occurs. If the drag and drop operation is not for file information, then no action is performed.
Since:
3.2.1
Author:
Peter Hollemans
See Also:
  • Constructor Details

    • FileTransferHandler

      public FileTransferHandler(Runnable runnable)
      Creates a new handler that calls the specified runnable.
      Parameters:
      runnable - the runnable object whose run() will be called when a drop operation occurs.
  • Method Details

    • getFileList

      public List getFileList()
      Gets the latest list of files from a drop operation.
      Returns:
      the list of files, or null if no drop operation has occurred.
    • getFile

      public File getFile()
      Gets the latest file from a drop operation. If a list of files is available, only the first file is returned.
      Returns:
      the file, or null if no drop operation has occurred.
    • canImport

      public boolean canImport(JComponent comp, DataFlavor[] flavors)
      Returns true if the data flavour contains a DataFlavour.javaFileListFlovor object. Users should not need to call this method -- it is called by AWT when a drag event occurs over the component. See the Java API documentation for javax.swing.TransferHandler for more info.
      Overrides:
      canImport in class TransferHandler
    • importData

      public boolean importData(JComponent comp, Transferable t)
      Returns true if the dropped data is imported successfully. Users should not need to call this method -- it is called by AWT when a drop event occurs on the component. See the Java API documentation for javax.swing.TransferHandler for more info.
      Overrides:
      importData in class TransferHandler