I have 3 circles -A, B, and C (the radii is already known). I want them to move them in a specified direction with a specified velocity, and stop them when they reach the boundary.
At any time t, i want to know the x and y coordinates of these circles. Is that possible?
Any hint on how to do the same?
I just have the circles so far, with the radii and current (x,y) positions.
And i forgot to mention that I want the circles to stop when they reach the upper boundary of the rectangle/ applet. And they should move in forward direction only ,i.e. theta = [0, 180] (randomly generated and known beforehand, say A moves 90degree continuosly from its previous position, B in 60 and C in 120 degrees respectively).
Each circle should move in a speed given by a ratio. say, Speed of A: B : C = 1: 2 : 3.
And i want to knwo the x,y coordinates after every period of, say 10seconds. (which i think i can get using basic trigonometry, and speed,distance,time thing. Is there any other way like a method or something ?).
Use a javax.swing.Timer. This runs on the EDT so it's safe to both query and modify your GUI. Just make sure to make sure the executions don't take too long to finish or the GUI will become non-responsive.
Really. Did you click on the link created for javax.swing.Timer? Did you see on that page not one but two links, one being "How to Use Timers" and the other "Using Timers in Swing Applications"? Did you click on those and read the pages they link to?