File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Stopping Animation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Stopping Animation" Watch "Stopping Animation" New topic
Author

Stopping Animation

Amil Mehmedagic
Greenhorn

Joined: Feb 27, 2004
Posts: 22
Hi!
I've coded two classes that create an array of the circle object and then move this array of circles by means of redrawing its position in the window.
The circles move clockwise at first and at each move there is a probability, as input by the user, that they are going to change direction. When they change direction the circles cannot again move clockwise. This is what the code below does.
What I need to do to complete the program is to stop the animation when all circles are moving anticlockwise. I've written the following steps, but I am having difficulties coding them in Java.
1. Check the position of each circle (i.e. whether it's moving clockwise or anticlockwise)
2. If it's moving anticlockwise then count the circle.
3. Repeat for all other circles.
4. When all circles are moving anticlockwise stop the animation.
I've figured out that an animation is stopped by the construct if (...) { }.
Can anybody help me code the above four steps into Java?
Below is the code of the two classes.
P. Sagdeo
Ranch Hand

Joined: Nov 13, 2003
Posts: 67
So what do you need help on?
Amil Mehmedagic
Greenhorn

Joined: Feb 27, 2004
Posts: 22
I need to stop the animation when all circles are moving anticlockwise
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Amil Mehmedagic
Stop the animation, when all circles are moving anticlockwise.

Does the program need to detect the circle moving?
So conditions to check the circles moving are required.
And then set the moving value of circles to stop.
Coding? you should code by yourself.

[ April 25, 2004: Message edited by: siu chung man ]

Francis Siu
SCJP, MCDBA
Amil Mehmedagic
Greenhorn

Joined: Feb 27, 2004
Posts: 22
My dilemma with this problem is that the instance variable clockwise, which checks whether the circle is moving clockwise or anticlockwise is an instance variable that can only be used in the Circle class, while the loop that controls the movements of circles in array is in the main class.
I think that that particular code, which checks whether the circle is moving anticlockwise, should be in the main method of the Main class.
But how do I check whether the circles are moving anticlockwise with no access to the clockwise variable?
What I want to do is check whether the circle is moving anticlockwise. If it is count it. Loop until all circles are moving anticlockwise, then stop.
But how do do this please, because I cannot access the clockwise variable from the Main method.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stopping Animation