import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class compo extends Applet
{
Label l1,l2,l3;
Button b1,b2;
TextField t1,t2,t3;
Choice c;
List l;
CheckboxGroup cg;
Checkbox c1,c2,c3,c4,c5,c6;
Checkbox r1,r2;
TextArea ta;
public void init()
{
setLayout(null);
l1 = new Label("Name : ");
l2 = new Label("Phone No.: ");
l3 = new Label("Place : ");
t1 = new TextField(50);
t2 = new TextField(50);
t3 = new TextField(50);
c = new Choice();
c.addItem("Managing Director");
c.addItem("Human Resources");
c.addItem("Software Engineer");
c.addItem("Team Leader");
c.addItem("Senior Programmer");
c.addItem("Programmer");
l = new List();
l.add("JEE");
l.add(".NET");
l.add("Mainframe");
l.add("SAP");
l.add("CORBA");
c1 = new Checkbox("B.Sc");
c2 = new Checkbox("M.Sc");
c3 = new Checkbox("M.Phil");
c4 = new Checkbox("B.E");
c5 = new Checkbox("M.C.A");
c6 = new Checkbox("M.E");
cg = new CheckboxGroup();
r1 = new Checkbox("Male",cg,false);
r2 = new Checkbox("Female",cg,false);
b1 = new Button("Submit");
b2 = new Button("Clear");
ta = new TextArea(50,25);
l1.setBounds(100,50,100,25);
t1.setBounds(200,50,200,25);
l2.setBounds(100,100,100,25);
t2.setBounds(200,100,200,25);
l3.setBounds(100,150,100,25);
t3.setBounds(200,150,200,25);
r1.setBounds(150,200,50,25);
r2.setBounds(300,200,100,25);
c1.setBounds(50,250,75,25);
c2.setBounds(125,250,75,25);
c3.setBounds(200,250,75,25);
c4.setBounds(275,250,75,25);
c5.setBounds(350,250,75,25);
c6.setBounds(430,250,75,25);
c.setBounds(100,300,135,25);
l.setBounds(300,300,100,25);
b1.setBounds(175,350,75,25);
b2.setBounds(275,350,75,25);
ta.setBounds(150,450,225,125);
add(l1); add(t1); add(l2); add(t2);
add(l3); add(t3); add(r1); add(r2);
add(c1); add(c2); add(c3); add(c4);
add(c5); add(c6); add(c); add(l);
add(b1); add(b2); add(ta);
b1.addActionListener(new a());
b2.addActionListener(new a());
r1.addItemListener(new b());
r2.addItemListener(new b());
c1.addItemListener(new b());
c2.addItemListener(new b());
c3.addItemListener(new b());
c4.addItemListener(new b());
c5.addItemListener(new b());
c6.addItemListener(new b());
}
class a implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
ta.append("\n"+t1.getText()+"\n");
ta.append(t2.getText()+"\n");
ta.append(t3.getText()+"\n");
ta.append(c.getSelectedItem()+"\n");
ta.append(l.getSelectedItem()+"\n");
}
if(e.getSource()==b2)
{
ta.setText("");
}
}
}
class b implements ItemListener
{
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==r1)
{
ta.append("Male"+"\n");
}
if(ie.getSource()==r2)
{
ta.append("Female"+"\n");
}
if(ie.getSource()==c1)
{
ta.append("B.Sc"+"\n");
}
if(ie.getSource()==c2)
{
ta.append("M.Sc"+"\n");
}
if(ie.getSource()==c3)
{
ta.append("M.Phil"+"\n");
}
if(ie.getSource()==c4)
{
ta.append("B.E"+"\n");
}
if(ie.getSource()==c5)
{
ta.append("M.C.A"+"\n");
}
if(ie.getSource()==c6)
{
ta.append("M.E"+"\n");
}
}
}
}
/* <body>
<applet code = "compo.class" height = 650 width = 500>
</applet>
</body> */Java
Java Applet - All the Components Demonstration

Written by
View ProfileSenthilvelan Sambamoorthy
Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.
