It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes dnd using control key..urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "dnd using control key..urgent" Watch "dnd using control key..urgent" New topic

dnd using control key..urgent

Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
Hello All,
I want to know if its possible to implement dnd using the Control key, like how its implemented in Windows systems, i.e, I press the Control Key & then start dnd..& is there any sample code ?

- Vinod<br />-------<br />SCJP2
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521

"JavaRanch, where the deer and the Certified play" - David O'Meara
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Drag n' Drop
eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
The getDragAction method of DragGestureEvent is supposed to return ACTION_COPY, ACTION_LINK, or ACTION_MOVE based on the state of the control and shift modifier keys. The action is actually determined in the DragGestureRecognizer. On windows and unix, ctrl gives ACTION_COPY, and ctrl-shift gives ACTION_LINK.
I haven't tried any of this yet. I'm just now reading the DnD chapter in Core Advanced Swing.....
Not much help, I know. Let me know if you get it to work!

<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
Here's some more:
The acceptDrag method of DropTarget takes an int dragOperation. A decision is made what to do with that value in the body of the method. You could subclass DropTarget if you have something different in mind, other than copying or moving.....
I agree. Here's the link:
subject: dnd using control key..urgent
jQuery in Action, 3rd edition