• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graphic Events

 
Nick Delauney
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to make graphics with Graphics G and the paint method. If I wanted to make some functionallity in which a user could drag a circle and it some where else on the canvas, how would I go about that. (I.E - like moving a checker peace in yahoo checkers). Any help is apreciated. Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One classic example of this comes with the J2SDK: see demos/applets/GraphLayout .
 
Jacquie Barker
author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way to do this is by tracking MouseEvents -- you can determine the (x,y) location of the mouse, compute whether it is "on" or "off" of the circle, and if it is "on", compute where the circle would have moved, then redraw it.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
[ October 16, 2003: Message edited by: Dirk Schreckmann ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic