package awt;
import java.awt.Frame;
import
java.awt.*;
import
java.awt.event.ActionEvent;
import
java.awt.event.ActionListener;
public class
Awt {
public
static void main(String[] args) {
Frame fm=new Frame();
Label lb = new Label("Student
Registration Form");
Label lb1 = new Label("Enter your
Name:");
Label lb2 = new Label("Enter your Area
of Interest:");
TextField txt1;
txt1 = new TextField(10);
TextArea area=new TextArea(10,100);
Label lb3=new Label("Education Level:");
Checkbox School,Graduate,Post;
School = new
Checkbox("School",true);
Graduate = new
Checkbox("Graduate",false);
Post = new
Checkbox("PostGraduate",false);
os=new Choice();
os.add("Unix");
os.add("Linux");
os.add("Windows");
os.add("Android");
os.add("Solaris");
Font myFont = new Font("Serif",Font.BOLD,24);
lb.setFont(myFont);
lb.setBackground(Color.orange);
lb.setBounds(130, 50, 290, 30);
lb1.setBackground(Color.green);
lb1.setBounds(20,110,100,30);
txt1.setBackground(Color.green);
txt1.setBounds(130,110,100,30);
lb2.setBackground(Color.green);
lb2.setBounds(20,150,150,30);
area.setBackground(Color.green);
area.setBounds(180, 150, 200, 100);
lb3.setBackground(Color.green);
lb3.setBounds(20, 310, 100, 30);
School.setBounds(130,300,100,50);
Graduate.setBounds(235,300,100,50);
Post.setBounds(380,300,110,50);
Label lb4=new Label("Familiar
OS:");
lb4.setBackground(Color.green);
lb4.setBounds(20,350,70,30);
os.setBounds(100,350,100,50);
List browser;
browser=new List();
browser.add("Internet Explorer");
browser.add("Edge");
browser.add("Chrome");
browser.add("FireFox");
browser.add("Opera");
Label lb5=new Label("Familiar
Browser:");
lb5.setBackground(Color.green);
lb5.setBounds(20,450,100,30);
browser.setBounds(125,450,105,70);
Label lb6=new Label("Gender:");
lb6.setBackground(Color.green);
lb6.setBounds(20,550,50,30);
CheckboxGroup cg=new CheckboxGroup();
Checkbox gender1=new
Checkbox("Male",cg,true);
Checkbox gender2=new
Checkbox("Female",cg,false);
Checkbox gender3=new Checkbox("Other",cg,false);
gender1.setBounds(70,550,50,30);
gender2.setBounds(120,550,70,30);
gender3.setBounds(190,550,50,30);
Button submit=new
Button("Submit");
submit.setBounds(300,600,50,30);
submit.setBackground(Color.MAGENTA);
fm.add(lb);
fm.add(lb1);
fm.add(txt1);
fm.add(lb2);
fm.add(area);
fm.add(lb3);
fm.add(School);
fm.add(Graduate);
fm.add(Post);
fm.add(lb4);
fm.add(os);
fm.add(lb5);
fm.add(browser);
fm.add(lb6);
fm.add(gender1);
fm.add(gender2);
fm.add(gender3);
fm.add(submit);
fm.setSize(600,700);
fm.setLayout(null);
fm.setVisible(true);
submit.addActionListener(new
ActionListener() {
public void actionPerformed (ActionEvent e)
{
System.out.println("Your Name :"+txt1.getText());
System.out.println("Your areas
of Interest:"+area.getText());
String s = null;
if (School.getState()== true){
s="School";
}
if (Graduate.getState()== true){
s="Graduate";
}
if (Post.getState()== true){
s="Post-Graduate";
}
System.out.println("Your
Education Level :"+s);
System.out.println("Familiar
OS :"+os.getSelectedItem());
System.out.println("Familiar
Browser is :"+browser.getSelectedItem());
String t = null;
if(gender1.getState()== true){
t="Male";
}
if(gender2.getState()== true){
t="Female";
}
if(gender3.getState()== true){
t="Others";
}
System.out.println("Gender
:"+t);
}
});
}//main function
}//class
No comments:
Post a Comment