• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic