posted 20 years ago
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