You are on page 1of 4

AJAVA (3360701) 2

Experiment:- 1B
Aim:- Draw ten red circles in a vertical column in the center of the applet.
Code:
import java.applet.*;
import java.awt.*;
public class p1b extends Applet
{
public void paint(Graphics g)
{
g.setColor(Color.red);
for(int i=0;i<10;i++)
{
g.fillOval(135,i*30,30,30);
}

}
}
/* <applet code="p1b.class" width="300" height="300"></applet>*/

Output:

TAPI DIPLOMA ENGINEERING COLLEGE 196470307045


AJAVA (3360701) 3

Experiment:- 2A
Aim:- Built an applet that displays a horizontal rectangle in its center. Let the rectangle fill with color
from left to right.
Code:
import java.applet.*;
import java.awt.*;
public class p2a extends Applet
{
Thread t =new Thread();
public void run(){

}
public void paint(Graphics g)
{
g.drawRect(19,89,161,21);
g.setColor(Color.green);
for(int i=20;i<180;)
{
try{
g.fillRect(i,90,5,20);
i+=5;
t.sleep(100);
}
catch(Exception e)
{
g.drawString("Error",10,10);
}

}
}
/* <applet code="p2a.class" width="200" height="200"></applet>*/

Output:

TAPI DIPLOMA ENGINEERING COLLEGE 196470307045


AJAVA (3360701) 10

Output:

TAPI DIPLOMA ENGINEERING COLLEGE 196470307045


AJAVA (3360701) 12

canvasColor();
}
if(cb3.isSelected())
{
b=255;
canvasColor();
}
else if(!cb3.isSelected()){
b=0;
canvasColor();
}
}
public void canvasColor()
{
c.setBackground(new Color(r,g,b));
}
public static void main(String arg[])
{
}
}
/* <applet code="p5a.class" width="300" height="100"></applet>*/

Output:

TAPI DIPLOMA ENGINEERING COLLEGE 196470307045

You might also like