• Post Reply Bookmark Topic Watch Topic
  • New Topic

Circular motion applet

 
richard dela cruz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Darryl Burke
Bartender
Posts: 5162
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!