public class FileTransferHandler
extends javax.swing.TransferHandler
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.Constructor and Description |
---|
FileTransferHandler(java.lang.Runnable runnable)
Creates a new handler that calls the specified runnable.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canImport(javax.swing.JComponent comp,
java.awt.datatransfer.DataFlavor[] flavors)
Returns true if the data flavour contains a
DataFlavour.javaFileListFlovor object. |
java.io.File |
getFile()
Gets the latest file from a drop operation.
|
java.util.List |
getFileList()
Gets the latest list of files from a drop operation.
|
boolean |
importData(javax.swing.JComponent comp,
java.awt.datatransfer.Transferable t)
Returns true if the dropped data is imported successfully.
|
public FileTransferHandler(java.lang.Runnable runnable)
runnable
- the runnable object whose run()
will
be called when a drop operation occurs.public java.util.List getFileList()
public java.io.File getFile()
public boolean canImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] flavors)
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.canImport
in class javax.swing.TransferHandler
public boolean importData(javax.swing.JComponent comp, java.awt.datatransfer.Transferable t)
javax.swing.TransferHandler
for
more info.importData
in class javax.swing.TransferHandler