Can't drag from List to JGoView?

Hey ya’ll, I have a Java application where I need to drag a string from a List widget onto a JGoView (SWT). Now, setting up the List as a DragSource works fine with no errors. However, whenever I try to set up the JGoView as the DropTarget, it gives me an error. See below:

[code]List myList = new List (shell, SWT.BORDER | SWT.V_SCROLL);

DragSource dragSource = new DragSource(myList, DND.DROP_COPY);
Transfer[] transferDataTypes = new Transfer[] {TextTransfer.getInstance()};
dragSource.setTransfer(transferDataTypes);
myList.setDragDetect(true);

JGoView myView = new JGoView(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
myView.setDropEnabled(true);
myView.setDragDropEnabled(true);
myView.initializeDragDropHandling();

DropTarget dropTarget = new DropTarget(myView, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT); [/code]
The bolded line is what gives me the following error:

Exception in thread "main" org.eclipse.swt.SWTError: Cannot initialize Drop at org.eclipse.swt.dnd.DND.error(Unknown Source) at org.eclipse.swt.dnd.DND.error(Unknown Source)
What’s causing this and how do I fix it? Are there other ways to set up JGoView objects as objects that can be dropped on?

Take a look at the Demo1SWT sample application. It allow dragging from an org.eclipse.swt.widgets.List to a JGoView. Actually, most of this is built into JGo. Calling JGoView.setDropEnabled(true) will create the DropTarget for you and also set up the DropListener.

Thanks for the reply. I removed that line, and it compiles properly now. However, it still won’t recognize drops. From SWT widget to SWT widget it works fine (as you would expect), but from SWT widget to JGo widget it doesn’t want to comply. If I have my listener like follows…

[code]
DropTarget dropTarget = myView.getDropTarget();
Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
dropTarget.setTransfer(types);

    dropTarget.addDropListener(new DropTargetAdapter()
    {
        public void dragEnter(DropTargetEvent event) 
        {
            if (event.detail == DND.DROP_DEFAULT) 
            {
                event.detail = DND.DROP_COPY;
            }
        }
        ...etc
    }[/code]

event.data is null in every single listener method. It isn’t when I drag from the list to say, a standard SWT text box. The mouse cursor does not change to the COPY cursor either… So why is this the case with a JGoView? Is there something I’m not configuring properly here?

Oh, and Demo1SWT didn’t seem to have anything about setting up DropTargetListeners…

JGoView has support for drag-and-drop built in. The DropEnabled property of JGoView needs to be true, but it is by default, so you don’t even have to set it. That’s why there’s no need for setting up a DropTargetListener in demo1SWT.

Note that JGoView implements DragSourceListener and DropTargetListener. So it has its own definition of dragEnter, for example, already. The same is true for the drop method. These methods are defined to handle both internal (within-the-JGoView) drag-and-drops as well as external (starting from another Control) drag-and-drops.

When you want to add drop handling from another Control, it’s best to override JGoView.onExternalDrop, and perhaps JGoView.computeAcceptableDrop, as Demo1View.java does in demo1SWT.