Package noaa.coastwatch.gui
Class FileTransferHandler
java.lang.Object
javax.swing.TransferHandler
noaa.coastwatch.gui.FileTransferHandler
- All Implemented Interfaces:
Serializable
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:
-
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
ConstructorDescriptionFileTransferHandler
(Runnable runnable) Creates a new handler that calls the specified runnable. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canImport
(JComponent comp, DataFlavor[] flavors) Returns true if the data flavour contains aDataFlavour.javaFileListFlovor
object.getFile()
Gets the latest file from a drop operation.Gets the latest list of files from a drop operation.boolean
importData
(JComponent comp, Transferable t) Returns true if the dropped data is imported successfully.Methods inherited from class javax.swing.TransferHandler
canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, getSourceActions, getVisualRepresentation, importData, setDragImage, setDragImageOffset
-
Constructor Details
-
FileTransferHandler
Creates a new handler that calls the specified runnable.- Parameters:
runnable
- the runnable object whoserun()
will be called when a drop operation occurs.
-
-
Method Details
-
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
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
Returns true if the data flavour contains aDataFlavour.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 forjavax.swing.TransferHandler
for more info.- Overrides:
canImport
in classTransferHandler
-
importData
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 forjavax.swing.TransferHandler
for more info.- Overrides:
importData
in classTransferHandler
-