drag'n'drop on glcanvas

hello,

does anyone know of a possibility to catch events when a file from the system (e.g. windows explorer) is dragged onto the glcanvas?

thanks!

I suspect that it’s possible through AWT or SWING, but I’ve never personally used it. If so these aren’t part of JOGL; rather part of the java GUI API.

Suggestion: search google: “AWT drag drop” or “SWING drag drop”.

Good luck!

I have barely any experience with this but look into java.awt.dnd.DropTarget and associating a DropTarget with the GLCanvas. Then experiment with the events you receive through it when you do the drag and drop action. I know this works with Swing widgets, and believe Swing’s support is built on top of the low-level support in the AWT, so I believe it should be possible.

thanks, but how do i add a DropTarget to the GLCanvas, i cant find an appropriate function for that.

Hi,

Looking at on of the DropTarget constructors seems to give a clue?


DropTarget

public DropTarget(Component c,
                  DropTargetListener dtl)
           throws HeadlessException

    Creates a DropTarget given the Component to associate itself with, and the DropTargetListener to handle event processing.

    The Component will receive drops only if it is enabled. 

See java.awt.Component.setDropTarget().

thanks it works now!