Java D&D, Java File Transfer, Java programming, j2se, java to standard edition, java drag and drop, D&D in java, Getting started with D&D in java, Java Data Transfer, JAVA API, Core java
2. ADVANCE JAVA
Author Profile
Ankit Desai
Ph.D. Scholar, IET, Ahmedabad University
Education: M. Tech. (C.E.), B. E. (I. T.)
Experience: 8 years (Academic and Research)
Research Interest: IoT, Big Data Analytics, Machine
Learning, Data Mining, Algorithms.
Classified e-Material 2
5. ADVANCE JAVA
Classified e-Material 5
DRAG AND DROP AND DATA TRANSFER
Drag and drop (DnD) support
List Component Drag Gesture
List packages
the data for transport
and declares it
supports MOVE and COPY
Drop
Text field imports
the data
Text field
Component
6. ADVANCE JAVA
Classified e-Material 6
DRAG AND DROP AND DATA TRANSFER
Clipboard transfer through cut or copy and paste
List
Component Cut or Copy
List packages
the data for transport
and declares it
supports MOVE and COPY
System
clipboard
System
clipboard Paste Action Textfield imports the Data
Textfield
Component
7. ADVANCE JAVA
Classified e-Material 7
DRAG AND DROP AND DATA TRANSFER
TransferHandler Class
Basic Methods
setDragEnabled(boolean)
setDropMode(DropMode)
setTransferHandler(TransferHandler)
Export Methods
getSourceActions(JComponent)
createTransferable(JComponent)
exportDone(JComponent, Transferable, int)
8. ADVANCE JAVA
Classified e-Material 8
DRAG AND DROP AND DATA TRANSFER
TransferHandler Class
Export Methods
getSourceActions(JComponent)
createTransferable(JComponent)
exportDone(JComponent, Transferable, int)
9. ADVANCE JAVA
Classified e-Material 9
DRAG AND DROP AND DATA TRANSFER
Sample Export Methods
int getSourceActions(JComponent c){
return COPY_OR_MOVE;
}
Transferable createTransferable(JComponent c){ return
new StringSelection(c.getSelection());
}
void exportDone(JComponent c, Transferable t, int
action){
if (action == MOVE){
c.removeSelection();
}
}
10. ADVANCE JAVA
Classified e-Material 10
DRAG AND DROP AND DATA TRANSFER
TransferHandler Class
Import Methods
canImport(TransferHandler.TransferSupport)
importData(TransferHandler.TransferSupport)
11. ADVANCE JAVA
Classified e-Material 11
CLASSES IN THE java.awt.datatransfer PACKAGE
Name Type
Clipboard Class
ClipboardOwner Interface
Dataflavor Class
StringSelection Class
Transferable Interface