Created
August 30, 2012 16:45
-
-
Save stepheng/3532821 to your computer and use it in GitHub Desktop.
Groovy Drag and Drop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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