This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Graphic Events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Graphic Events" Watch "Graphic Events" New topic

Graphic Events

Nick Delauney
Ranch Hand

Joined: Sep 28, 2002
Posts: 43
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.

N.D:"Anything worth having, takes time to get"
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

One classic example of this comes with the J2SDK: see demos/applets/GraphLayout .

[Jess in Action][AskingGoodQuestions]
Jacquie Barker
Ranch Hand

Joined: Dec 20, 2000
Posts: 201
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.

Author of Beginning Java Objects, Beginning C# Objects, and Taming the Technology Tidal Wave
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum...
[ October 16, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Graphic Events
It's not a secret anymore!