0% found this document useful (0 votes)
29 views

Experiment:-1B: Aim: - Code

The document describes an experiment with the following goals: 1. Draw ten red circles in a vertical column in the center of an applet 2. Build an applet that displays a horizontal rectangle in its center and fills it with green color from left to right over time 3. Create an applet with three checkboxes to set RGB color values and change the background color of the canvas

Uploaded by

Hello
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Experiment:-1B: Aim: - Code

The document describes an experiment with the following goals: 1. Draw ten red circles in a vertical column in the center of an applet 2. Build an applet that displays a horizontal rectangle in its center and fills it with green color from left to right over time 3. Create an applet with three checkboxes to set RGB color values and change the background color of the canvas

Uploaded by

Hello
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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