Drop item from palette to JGoView

Rather then use a JGoPalette I have a JList holding a string representation of my Node(s) in addition to an image i.e. a bullet in from of each text I for the most part used the code which you provide in Demo1List extends JList. My problem is that I cannot trigger the necessaryevent in order for the drop to be picked up by the view. I have the following in my JList class and I also created a AppAction with the name of the state which I select with no luck. Im not sure what Im missing. Is there a way to directly trigger a drop event so that my drop() method in my JGoView class is called. I would like to do something like view.fireUpdate(JGoViewEvent.EXTERNAL_OBJECTS_DROPPED, 0, state); but would this ever work?



public void dragGestureRecognized(DragGestureEvent e)

{

WorkflowStateNode state = (WorkflowStateNode)getSelectedValue();

if (state != null) {

//tried the following below with no luck StringSelectio n sel = new StringSelection(state.getText());

e.startDrag(DragSource.DefaultCopyDrop, sel, this);





Thank you for your time

The Demo1 example does what you want – look at the Demo1View class (extending JGoView) that overrides the drop method, and at Demo1List (extending JList) that implements the dragGestureRecognized method.

Thank you walter. I have one more question. I populate my JList directly with the node objects. Is it possible to drag the node object directly without having to pass a string representation of the node i.e.



public void dragGestureRecognized(DragGestureEvent e)

{

WorkflowStateNode state = (WorkflowStateNode)getSelectedValue();

if (state != null) {

//pass the node directly here in order for it to be obtained by the drop method in the JGoView class & nbsp; e.startDrag(DragSource.De faultCopyDrop, state, this);

Yes, but not a node since JGoNode et al don’t implement Transferable. Instead, create a JGoSelection or a JGoDocument that contains the object(s) that you want to drop.
Take a look at the JGoView.doDrop to see what happens on the standard drop – it copies the objects that are in the collection that is the Tranferable data. Look at the definition of JGoView.dragGestureRecognized to see the standard way of starting a drag-and-drop. (One minor note: in the next release the implementation of this latter method will change to transfer a JGoDocument rather than a JGoSelection.)