import java.awt.*;
import java.applet.*;
import java.util.*;
public class abc extends Applet implements Runnable
{
Thread t;
Button btn;
Checkbox cb, cb1;
CheckboxGroup cbg;
TextField tf = new TextField("Ankit",30);
public void run()
{
try
{
while(true)
{
Random rnd = new Random();
int r = rnd.nextInt(254);
int g = rnd.nextInt(254);
int b = rnd.nextInt(254);
setBackground(new Color(r,g,b));
t.sleep(1000);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void init()
{
t = new Thread(this);
t.start();
cbg = new CheckboxGroup();
btn = new Button("Click Me!");
cb = new Checkbox("Hindi", false, cbg);
cb1 = new Checkbox("English", false, cbg);
setLayout(new FlowLayout(FlowLayout.RIGHT));
add(btn);
add(cb);
add(cb1);
add(new Checkbox("French",true, cbg));
add(tf);
}
public void paint(Graphics g)
{
Color redc = new Color(255, 0, 0);
g.fillRect(100,200,100,100);
g.setColor(Color.blue);
g.fillRect(300,300,50,50);
g.drawOval(0, 0, 200, 100);
g.fillOval(255,255,255,255);
}
}
/*
<applet code="abc" width="500" height="500"></applet>
*/
OutPut
import java.applet.*;
import java.util.*;
public class abc extends Applet implements Runnable
{
Thread t;
Button btn;
Checkbox cb, cb1;
CheckboxGroup cbg;
TextField tf = new TextField("Ankit",30);
public void run()
{
try
{
while(true)
{
Random rnd = new Random();
int r = rnd.nextInt(254);
int g = rnd.nextInt(254);
int b = rnd.nextInt(254);
setBackground(new Color(r,g,b));
t.sleep(1000);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void init()
{
t = new Thread(this);
t.start();
cbg = new CheckboxGroup();
btn = new Button("Click Me!");
cb = new Checkbox("Hindi", false, cbg);
cb1 = new Checkbox("English", false, cbg);
setLayout(new FlowLayout(FlowLayout.RIGHT));
add(btn);
add(cb);
add(cb1);
add(new Checkbox("French",true, cbg));
add(tf);
}
public void paint(Graphics g)
{
Color redc = new Color(255, 0, 0);
g.fillRect(100,200,100,100);
g.setColor(Color.blue);
g.fillRect(300,300,50,50);
g.drawOval(0, 0, 200, 100);
g.fillOval(255,255,255,255);
}
}
/*
<applet code="abc" width="500" height="500"></applet>
*/
OutPut
0 comments:
Post a Comment