Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Name:_____________________________

Std X, Sec ____, Roll # _____


Index No. __________________

Page -1
Page -2
LOYOLA SCHOOL
JAMSHEDPUR – 831001
JHARKHAND

DISCLAIMER

I ______________________ of Std. X ___, hereby declare that all

information and work in this Computer Application assignment

has been prepared and presented in accordance with academic

rules and ethical conduct.

_____________________
(Signature of the student)

Page -3
Q. Write a program in Java to generate a graphic applet line animation
that swivels from top left corner of the screen, The line should be blue in
color.

Program Code:

import java.awt.*;
import java.applet.*;

public class Line_Animation extends Applet


{
public void paint(Graphics g)
{
g.setColor(Color.black);
g.fillRect(0,0,1365,1365);
Color rd,gr,ye;
rd=Color.red;
gr=Color.blue;
ye=Color.green;
int rn;
int i,j;long delay;
for(i=0;i<=1365;i+=100)
{
rn=(int)Math.random();
g.setColor(rd);
for(j=100;j<=500;j+=10)
{
g.drawLine(rn+30,rn+45,i,j);rn++;
g.setColor(gr);
g.drawLine(rn+30,rn+45,i,j);rn++;
for(delay=1;delay<=999999;delay++);
}
for(delay=1;delay<=999999;delay++);
}

}
}
Page -4
Execution:

Output:

Page -5
Variable Description

Variable Name Data Type Description


Line_Animation class Class name
Object of graphics
g object
class
Objects of color
rd, gr, ye Object
class
i int Loop variable
j int Loop variable
Time delay loop
delay long
variable
… … …
… … …
… … …
… … …
… … …
… … …
… … …
… … …
… … …

Page -6
Conclusion & Bibliography:

…………………………………………………………………………………
…………………………………………………….
…………………………………………………………………………………
…………………………………………………….
…………………………………………………………………………………
…………………………………………………….
…………………………………………………………………………………
…………………………………………………….
…………………………………………………………………………………
…………………………………………………….
…………………………………………………………………………………
…………………………………………………….

This page is not mandatory

Page -7

You might also like