Selection larger than the JGoView


I want allow the mouse selections when the mouse button is released outside the JGoView. For example, if I start my selection from the point (50,50) to a point on the top-left of the JGoView, but too much at the top left, not inside the view; I want my selection is a Rectangle (0,0,50,50). I don’t want the selection is cancelled because I released the button when I wasn’t in the view.
I try to use a mouse listener but I can’t receive any event.
For testing, I also try to override onDragDropEnd(DragSourceDropEvent e) methode and do a doMouseUp() in every case. It did almost what I want about the selections, but it also did much other things I don’t want when I drag and drop the nodes.
Do you have an idea to do it?


If you don’t mind turning off dragging out of the JGoView, you can call JGoView.setDragEnabled(false). That controls whether drag-and-drop (gesture recognition) occurs, not whether the user can “drag” any objects in the general sense. All dragging that starts within the view will end in it, even if the mouse is beyond the bounds of the view.


When I use JGoView.setDragEnabled(false), I don’t see any difference. It doesn’t prevent me to drag objects to an other JGoView.
I have an other question. When I drag and drop a JGoNode from a JGoView to an other. Can I move it by default and copy it when I press the Control key? It seems I always copy it.


That’s odd–it worked for me when I tried it. Maybe some other code is resetting it to true without your knowledge.
Moving objects between windows is not the default, and I don’t think there is a switch to cause such behavior. I suspect you could override JGoView.dragDropEnd and call deleteSelection if the drop was successful.


You are right, something is overriding it. It seems setDragEnabled can be set to true when the JGoView.addNotify() is called (by java.awt.Window.pack() for example). I also use a component for docking my windows, so I think this method is called from time to time. When I success to do a setDragEnabled(false) so it works.
I think I will override JGoView.addNotify() to be sure I cannot Drag out of my window.
Then when I will press the control key, I will change the state and let it be draggable.
About moving a node from one view to an other, I don’t know how to do. It’s not too important, I will see later.
Thanks for your help.


I didn’t changed addNotify, because I couldn’t call the super.super.addNotify() method unfortunately!
So I did that and it works:
public void initializeDragDropHandling() {
boolean bDrag = isDragEnabled();
boolean bDrop = isDropEnabled();
Now it’s really easier to select several nodes near from the top or left of the view.
But I have a new problem. When I move a JGoNode (or severals) too far on the top or on the left of the view, I can lose it. It’s position is negative on X or Y, so not in the displayable view.


An other problem again, I didn’t see before.
If I use setDragEnabled(false). The JGoView never scroll when I do a selection or when I drag an object in the same view.


I overrided the JGoView.doMouseMove() method. I success to scroll the window when I select. The selection works but really don’t look nice.
public boolean doMouseMove(int modifiers, Point dc, Point vc) {
if (isDragEnabled()) {
if ((modifiers & MouseEvent.CTRL_MASK) == 0) {
} else {
if ((modifiers & MouseEvent.CTRL_MASK) != 0) {
if (!isDragEnabled()
&& ((modifiers & MouseEvent.MOUSE_DRAGGED) != 0)) {
return super.doMouseMove(modifiers, dc, vc);