Skip to content

Instantly share code, notes, and snippets.

@stepheng
Created August 30, 2012 16:45
Show Gist options
  • Save stepheng/3532821 to your computer and use it in GitHub Desktop.
Save stepheng/3532821 to your computer and use it in GitHub Desktop.
Groovy Drag and Drop
swing.edt {
frame( id: 'mainFrame',
title: 'title',
defaultCloseOperation: JFrame.EXIT_ON_CLOSE,
show: true,
size: [300, 300]) {
textLabel = label(text:"Drag file here", constraints:BL.NORTH)
mainFrame.dropTarget = [
drop: { dtde ->
def t = dtde.transferable
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_REFERENCE)
t.getTransferData(DataFlavor.javaFileListFlavor).each {
println it
}
}
}
] as DropTarget
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment