new DropTarget(this.jTextField1,DnDConstants.ACTION_COPY_OR_MOVE,this);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public void dragEnter(DropTargetDragEvent dtde) {
/**@todo Implement this java.awt.dnd.DropTargetListener method*/
//throw new java.lang.UnsupportedOperationException("Method dragEnter() not yet implemented.");
}
public void dragOver(DropTargetDragEvent dtde) {
/**@todo Implement this java.awt.dnd.DropTargetListener method*/
//throw new java.lang.UnsupportedOperationException("Method dragOver() not yet implemented.");
}
public void dropActionChanged(DropTargetDragEvent dtde) {
/**@todo Implement this java.awt.dnd.DropTargetListener method*/
//throw new java.lang.UnsupportedOperationException("Method dropActionChanged() not yet implemented.");
}
public void dragExit(DropTargetEvent dte) {
/**@todo Implement this java.awt.dnd.DropTargetListener method*/
//throw new java.lang.UnsupportedOperationException("Method dragExit() not yet implemented.");
}
public void drop(DropTargetDropEvent dtde) {
/**@todo Implement this java.awt.dnd.DropTargetListener method*/
//throw new java.lang.UnsupportedOperationException("Method drop() not yet implemented.");
try{
Transferable tr = dtde.getTransferable();
if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)){
dtde.acceptDrop(dtde.getDropAction());
String s = (String) tr.getTransferData(DataFlavor.stringFlavor);
this.jTextField1.setText(this.jTextField1.getText()+s);
dtde.dropComplete(true);
}else{
dtde.rejectDrop();