Applet Demo
Applet Demo
JAVA
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
//<applet code="Appletdemo" height="500"
width="500"></applet>
public class Appletdemo extends Applet implements
ActionListener
{
String s;
Button b1,b2,b3;
public void init()
{
b1=new Button("circle");
b2= new Button("Rect");
b3 = new Button("Color circle");
add(b1);
add(b2);
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
s=ae.getActionCommand();
repaint();
}
public void paint(Graphics g)
//********
{
try
{
if(s.equals("circle"))
g.drawOval(122,53,62,75);
if(s.equals("Rect"))
g.drawRect(122,60,122,60);
if(s.equals("Color circle"))
g.fillOval(122,53,62,75);
}
catch(NullPointerException e)
{
}
}
OUTPUT: