Write a java Applet Program TO display Check Box (Tea Coffee)
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class NewApplet extends Applet implements ItemListener
{
Checkbox c=null,t=null;
public void init()
{
c=new Checkbox("coffee");
t=new Checkbox("tea");
add(c);
add(t);
c.addItemListener(this);
t.addItemListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
repaint();
}
public void paint(Graphics g)
{
if(c.getState()==true)
{
g.drawString("cofee",100,100);
}
if(t.getState()==true)
{
g.drawString("tee",120,100);
}
}
}
Leave a Comment