Drag Drop Between goViews

Hi all,
Is there any way to drag and drop JGoIconicNode between 2 goViews? I want to use 1 goView for object container and 1 for object space. I need drag and drop JGoIconicNodes.

Yes, that’s what the JGoPalette is intended for. THe JGoPallete is just a simple subclass of JGoView that arranges JGoObjects that can be dragged and dropped on another JGoView.

Of course, you don't need to use JGoPalette if you don't want to. By default, you can drag from a standard JGoView to another JGoView. You may want to set the Modifiable property to false on your source JGoView, otherwise dragging the object from the source JGoView will move the object in the source view as well as making a copy of it in the destination view.

Actually i wanted to do what you explained. I want to MOVE the objects from one view to another. Are there any code snippets around?
Thanks for help…

To move an object from one view to another, you just need to detect the fact that the drag drop operation has completed and was successful and then delete the object from the source view. The rest will happen by default. To do so, you can create a subclass of JGoView for your source view and override onDragDropEnd() as follows:

public void onDragDropEnd(DragSourceDropEvent e) {
boolean bInternalDragDrop = isInternalDragDrop();
if (e.getDropSuccess() && bInternalDragDrop) {


I am dragging a JIconicNode from one JGoView to another and while I am dragging, I only have the mouse cursor changed. I need to move the Icon also while dragging. What should I set to true in order for this thing to work? DragsRealtime or DragsSelectionImage are not working.

And also does anybody know how to get the actual JGoObject that is being dragged? I am using an override for dragGestureRecognized() when the drag operation starts and an override for onDrop() when it ends. But getting the JGoObject out of the DragGestureEvent or DropTargetDropEvent is killing me :)

Thank you!

I’m afraid there are limits to what one can do when dragging an object between windows.

When dragging within a JGoView, JGo can of course paint the object as it moves within the JGoView window.
When dragging between JGoViews, the JGoViews may not even be adjacent, so there is no abilitiy to paint to a window JGo doesn't own. When dragging between JGoViews, JGo simply uses the standard Java drag and drop mechanism and that only provides you the ability to change the cursor during the drag.

Thank you for your reply! I have managed to do the dragging from one JGoView to another.

First of all, I had one JGoView(like a toolbar) inside another JGoView(the main canvas).

When I drag a JGoIconicNode from the toolbar to the main canvas I add a new object (a JGoImage) to the main canvas and I am changing its location on onDragOver() event. It is being painted on the main canvas like it is being dragged.

I get the source using dragGestureRecognized() from the toolbar and I use onDrop() from the main canvas to know when to drop the object.