wood burning stoves*
The moose likes Applets and the fly likes Circular motion applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Circular motion applet" Watch "Circular motion applet" New topic
Author

Circular motion applet

richard dela cruz
Greenhorn

Joined: Oct 03, 2012
Posts: 1
can anyone tell me an easy way to make a single dot move in circular motion? so far... i've only done these...
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1761
    
    7

Think about how you would normally find the X and Y coördinates of a point on the unit circle.
Then think about how you could use that same logic to implement a dot that moves in a circular motion.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

Don't use Thread#sleep(...) in a painting method override or indeed in any code that runs on the EDT.

Use a javax.swing.Timer for animation. Change the coordinates and call repaint().


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Circular motion applet