File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Drag and Drop: what should my sources and targets be? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drag and Drop: what should my sources and targets be? " Watch "Drag and Drop: what should my sources and targets be? " New topic
Author

Drag and Drop: what should my sources and targets be?

Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
D-n-d gurus, I need your help. I'm creating a backgammon game, and need help in figuring out what components should be sources, and what should be targets.
The way the board works is that each point on the board is a separate object. The checkers (also separate objects) are contained within the point in a vector. Checkers are added/subtracted to/from the point by adding/removing them to/from the vector, then calling a custom method which redraws the checkers on the point. The board is just a large JPanel, and the points are positioned within the board using explicit positioning.
I would like to add drag-and-drop capabilities to the board, so that the user can click and drag a checker to another point. After reading the drag-and-drop tutorial, I'm more confused than ever.
My question to you: what should my drag sources be, and what should the targets be? I'm assuming that the points should be drop targets, since they will be receiving the dropped checkers. Should the checkers or points be drag sources?
Also, since a checker is just a glorified JPanel, what do I need to do to make it draggable?
Any help would be appreciated!


There's nothing more dangerous than a resourceful idiot. ---Dilbert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drag and Drop: what should my sources and targets be?
 
Similar Threads
Using incomplete key to get a value from map.
SCBCD certification primer: A comprehensive article on SCBCD
Autoscrolling for marquee selection
Transfer drop to sub-component (need help with)
Popup lists