Extra click to drop

Hi, this is hopefully an easy one.

In my JGoView instance I have non-resizable nodes that consist of a a background JGoRectangle, JGoText boxes and to pretty straightforward subclasses of JGoPort acting as to and from connectors at the top and bottom. I’ve got everything displaying correctly, but I can’t get the behavior of my nodes themselves correct.

I want:

  1. Single mouse click selects the entire node (highlighted in green as appears to be default is fine).
  2. Click and drag moves the node. When the mouse button is released, the node should drop into it’s new location and be selected.

Number 1 is working. However, when I do a click and drag the object remains attached to my pointer, still dragging, regardless of whether I still have the mouse button down. I have to click a second time to drop it and then it does not appear to be selected.

I have another project where I’m getting the behavior I want, but I can’t figure out what the difference is. I’m hoping someone knows the property/properties I need to set to get the behavior I want.

Thanks,
Mark

That’s definitely not standard behavior, as you can see by running any of the sample applications.
Have you overridden any of the mouse event handlers on JGoView?

Well, I’ve isolated it a bit further. I am extending JGoDocument. The constructor for this subclass has one argument and immediately calls super(). When I use the Constructor with the argument it gives me the “bad” behavior. When I change the Constructor to have no arguments then I get the “good” behavior which appears to be standard.

Any clue why this might be happening? I could easily move this argument out of the constructor and just use a setter to pass it in after construction, but that isn’t ideal.

Thanks,
Mark

And to answer your actual question , no I’m not overriding any mouse events on JGoView. I can reproduce this behavior using an unmodified or subclassed JGoView object.

Mark

Are there any exceptions happening that are being muffled? In particular, are your JGoDocument and all of its JGoObjects serializable? Perhaps your JGoObject class has a reference to something that isn’t serializable, and that causes an exception during the drag-and-drop.

Sorry for the delay. I got caught up in something else. Now I’m back to this problem.

Your guess seems to be correct. My subclass of JGoDocument has a reference to one of my domain objects. If I comment out any place where that reference is set, the correct drag/drop behavior occurs.

I’m a bit of a Java newbie if that wasn’t obvious. The domain object in question does not implement the java.io.Serializable interface. This is what you mean by serializable, yes? Can you recommend a resource to explain how best to do this?

Alternatively, maybe I can not store a reference to the object itself, but just an ID and do a lookup when I need the object. I was hoping to streamline that, but maybe it is the best approach.

Thanks for your help.

Mark U.

Yes, I meant java.io.Serializable. JGoObject and JGoDocument, for example, implement that, and make sure that all of their fields (data members) are either serializable or are declared “transient”.
I’m not familiar with your application/domain objects, so I can’t recommend whether or not you want to serialize your own objects. Certainly, what you suggest is a good idea: declare your reference transient and add a field that is the ID. Make sure the property getter uses the reference field as a cached reference to your object.

Walter,

Just wanted to thank you very much for your assistance. With your pointers I was able to figure out how to eliminate the serialization errors and get the correct drag and drop behavior.

I appreciate it greatly!

Mark U.