Created
December 1, 2015 10:21
-
-
Save cy6erGn0m/ba1d95d708c9d6195010 to your computer and use it in GitHub Desktop.
Drag and drop example
This file contains 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
package dnd | |
import java.awt.* | |
import java.awt.dnd.* | |
import javax.swing.* | |
fun main(args: Array<String>) { | |
SwingUtilities.invokeAndWait { | |
val f = JFrame("test") | |
f.defaultCloseOperation = JFrame.EXIT_ON_CLOSE | |
f.isLocationByPlatform = true | |
f.preferredSize = Dimension(800, 600) | |
f.size = Dimension(800, 600) | |
f.isVisible = true | |
val dl = object : DropTargetListener { | |
override fun drop(dtde: DropTargetDropEvent?) { | |
println("drop") | |
} | |
override fun dragOver(dtde: DropTargetDragEvent?) { | |
println("over") | |
} | |
override fun dragExit(dte: DropTargetEvent?) { | |
println("exit") | |
} | |
override fun dropActionChanged(dtde: DropTargetDragEvent?) { | |
println("changed") | |
} | |
override fun dragEnter(dtde: DropTargetDragEvent?) { | |
println("enter") | |
} | |
} | |
val target = DropTarget(f, DnDConstants.ACTION_COPY_OR_MOVE, dl, true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment