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(TransferHandler.TransferSupport info)
      Overrides:
      canImport in class TransferHandler
    • importData

      public boolean importData(TransferHandler.TransferSupport info)
      Overrides:
      importData in class TransferHandler