|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.TransferHandler com.alee.extended.drag.FileDragAndDropHandler
public class FileDragAndDropHandler
Custom TransferHandler that provides easy and convenient way to support files DnD to/from any Swing component.
To provide drag functionality overridefilesDropped()
method and enable drag operation through methods or constructor.
You will also have to call "exportAsDrag" method of TransferHandler to initialize drag operation from where you want it to start.
Usually that action is done from MouseMotionListener drag method.
To provide drop functionality imply override filesDropped()
method and enable drop operation through methods or constructor.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.TransferHandler |
---|
javax.swing.TransferHandler.DropLocation, javax.swing.TransferHandler.TransferSupport |
Field Summary | |
---|---|
protected int |
dragAction
Desired drag action. |
protected boolean |
dragEnabled
Whether files drag is enabled or not. |
protected boolean |
dropEnabled
Whether files drop is enabled or not. |
Fields inherited from class javax.swing.TransferHandler |
---|
COPY, COPY_OR_MOVE, LINK, MOVE, NONE |
Constructor Summary | |
---|---|
FileDragAndDropHandler()
Constructs new FileDragAndDropHandler that allows only file drop operations. |
|
FileDragAndDropHandler(boolean dragEnabled,
boolean dropEnabled)
Constructs new FileDragAndDropHandler that might allow drag and/or drop operations. |
Method Summary | |
---|---|
boolean |
canImport(javax.swing.TransferHandler.TransferSupport info)
|
protected java.awt.datatransfer.Transferable |
createTransferable(javax.swing.JComponent c)
|
java.io.File |
fileDragged()
Informs that drag action has started and dragged file should be provided. |
java.util.List<java.io.File> |
filesDragged()
Informs that drag action has started and list of dragged files should be provided. |
boolean |
filesDropped(java.util.List<java.io.File> files)
Informs that specified files were dropped. |
int |
getDragAction()
Returns desired drag action. |
int |
getSourceActions(javax.swing.JComponent c)
|
boolean |
importData(java.awt.datatransfer.Transferable t)
Performs data import checks and action. |
boolean |
importData(javax.swing.TransferHandler.TransferSupport info)
|
boolean |
isDragEnabled()
Returns whether drag is enabled or not. |
boolean |
isDropEnabled()
Returns whether drop is enabled or not. |
void |
setDragAction(int action)
Sets desired drag action. |
void |
setDragEnabled(boolean enabled)
Sets whether drag is enabled or not. |
void |
setDropEnabled(boolean enabled)
Sets whether drop is enabled or not. |
Methods inherited from class javax.swing.TransferHandler |
---|
canImport, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation, importData |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean dragEnabled
protected int dragAction
protected boolean dropEnabled
Constructor Detail |
---|
public FileDragAndDropHandler()
public FileDragAndDropHandler(boolean dragEnabled, boolean dropEnabled)
dragEnabled
- whether drag operations are alloweddropEnabled
- whether drop operations are allowedMethod Detail |
---|
public boolean isDragEnabled()
false
is set any drag actions will be blocked.
public void setDragEnabled(boolean enabled)
false
is set any drag actions will be blocked.
enabled
- whether drag is enabled or notpublic int getDragAction()
TransferHandler.COPY
or TransferHandler.MOVE
constant.
public void setDragAction(int action)
TransferHandler.COPY
or TransferHandler.MOVE
constant.
action
- new desired drag actionpublic int getSourceActions(javax.swing.JComponent c)
getSourceActions
in class javax.swing.TransferHandler
protected java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent c)
createTransferable
in class javax.swing.TransferHandler
public java.util.List<java.io.File> filesDragged()
public java.io.File fileDragged()
public boolean isDropEnabled()
false
is returned any drop actions are blocked.
public void setDropEnabled(boolean enabled)
false
is set any drop actions will be blocked.
enabled
- whether drop is enabled or notpublic boolean canImport(javax.swing.TransferHandler.TransferSupport info)
canImport
in class javax.swing.TransferHandler
public boolean importData(javax.swing.TransferHandler.TransferSupport info)
importData
in class javax.swing.TransferHandler
public boolean importData(java.awt.datatransfer.Transferable t)
t
- dropped transferable
public boolean filesDropped(java.util.List<java.io.File> files)
files
- list of dropped files
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |