File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Graphic Events" Watch "Graphic Events" New topic
Author

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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


[Jess in Action][AskingGoodQuestions]
Jacquie Barker
author
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
Sheriff

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: http://aspose.com/file-tools
 
subject: Graphic Events