usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< PreviousNext >>

Code to Animate a Body (Circle) Across the Canvas Component in Java




How to Draw on the Java Canvas

We'll will draw a circle - our body - using the fillOval method of the Graphics object.



Animating a Body

To make the circle appear to move across the canvas, i.e., animate the circle, we'll simply draw the circle repeatedly, changing its position progressively as well as clearing the previous image.

Create 2 new class files; File, New.
Call them PanselsMovingBody and MovingBody.
Type out the adjoining Java code for animating an image body across the canvas component.



Note: The code module for our Facet class will remain the same for the rest of the demonstrations in this category.
Hence it will be left out hence forth.










<< PreviousNext >>