File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Circular motion applet

richard dela cruz

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

Joined: Mar 10, 2008
Posts: 1951

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

Joined: May 03, 2008
Posts: 5115

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:
subject: Circular motion applet
It's not a secret anymore!