student form
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class studentdemo extends Frame implements ActionListener
{
String msg;
Button b1=new Button("save");
Button b2=new Button("Reset");
Label l11=new Label("student registration Form",Label.CENTER);
Label l1=new Label("Name:",Label.LEFT);
Label l2=new Label("Age:",Label.LEFT);
Label l3=new Label("Gender:",Label.LEFT);
Choice age=new Choice();
TextField t1=new TextField(20);
CheckboxGroup cbg=new CheckboxGroup();
Checkbox ck1=new Checkbox("Male",false,cbg);
Checkbox ck2=new Checkbox("Female",false,cbg);
public studentdemo()
{
addWindowListener(new myWindowAdapter());
setBackground(Color.cyan);
setForeground(Color.black);
setLayout(null);
add(l11);
add(l1);
add(l2);
add(l3);
add(t1);
add(age);
add(ck1);
add(ck2);
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
age.add("15");
age.add("16");
age.add("17");
age.add("18");
age.add("19");
t1.setEchoChar('*');
l1.setBounds(25,65,90,20);
l2.setBounds(25,90,90,20);
l3.setBounds(25,120,90,20);
l11.setBounds(100,40,280,20);
t1.setBounds(120,65,170,20);
age.setBounds(120,90,50,20);
ck1.setBounds(120,120,50,20);
ck2.setBounds(170,120,60,20);
b1.setBounds(120,350,50,30);
b2.setBounds(200,350,50,30);
}
public void paint(Graphics g)
{
g.drawString(msg,200,450);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("save"))
{
msg="details saved";
repaint();
}
if(ae.getActionCommand().equals("Reset"))
{
t1.setText("");
}
}
public static void main(String arg[])
{
studentdemo s=new studentdemo();
s.setSize(500,500);
s.setTitle("student Registration");
s.setVisible(true);
}
}
class myWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
No comments:
Post a Comment