10 Aug

My First Java Animation

hey there, ┬áthis is my first animation made in JAVA …. I know its nothing fancy but yes its a step…

Its just a simple Ball bouncing of the boundary of the applet. I just wanted to learn some new stuffs so opened a book and started. :P

What i did was that first Defined run(), start() and stop() method overiding that of Runnable Interface. In run() method is used the sleep method to repaint my applet in extremely small intervals of time i chose 333ms.. These methods were defined in a class BOUNCE

Then i made another class in same package BALL in whose constructor i initialized xpos, ypos to define the starting location of ball and the dx and dy to define the speed. color and size of the ball were also initialized .
Then another method draw() is declared in which I set color and the made a fillOval with the initialized parameters…