-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponents.java
More file actions
76 lines (75 loc) · 2.57 KB
/
Components.java
File metadata and controls
76 lines (75 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="Components" width=655 height=700>
</applet>
*/
public class Components extends Applet implements ActionListener,ItemListener
{
String msg1,msg2,msg3,msg4,msg5;
TextField fname,lname;
Button enter,cancel;
Checkbox male,female;
CheckboxGroup cbg;
Choice qualify,occup;
TextArea address;
public void init()
{
cbg = new CheckboxGroup();
setLayout(new FlowLayout(FlowLayout.LEFT,50,30));
fname=new TextField(10);
lname=new TextField(10);
enter=new Button("Enter");
cancel=new Button("Cancel");
address=new TextArea(5,15);
Label fname1=new Label("First Name:",Label.RIGHT);
Label lname1=new Label("Last Name:",Label.LEFT);
Label gender=new Label("Gender:",Label.RIGHT);
Label addr=new Label("Address:");
Label qual=new Label("Qualifiction:",Label.RIGHT);
Label occu=new Label("Occupation:",Label.RIGHT);
male=new Checkbox("MALE",cbg,false);
female=new Checkbox("FEMALE",cbg,false);
qualify=new Choice();
occup=new Choice();
qualify.add("Under Graduate"); qualify.add("Post Graduate");
occup.add("Engineer(Student)");occup.add("Doctor");occup.add("Mechanic");
add(fname1);add(fname);add(lname1);add(lname);
add(addr);add(address);add(gender);add(male);
add(female);add(qual);add(qualify);add(occu);
add(occup);add(enter);add(cancel);
fname.addActionListener(this);lname.addActionListener(this);
male.addItemListener(this);female.addItemListener(this);qualify.addItemListener(this);
occup.addItemListener(this);enter.addActionListener(this);cancel.addActionListener(this);
}
public void itemStateChanged(ItemEvent ie)
{
repaint();
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==enter)
{
repaint();
msg1="First Name:"+fname.getText();
msg2="Last Name:"+lname.getText();
msg3="Address:"+address.getText();
msg4="Gender:"+cbg.getSelectedCheckbox().getLabel();
msg5="Qualification:"+occup.getSelectedItem();
}
if(ae.getSource()==cancel)
{
repaint();
msg1="";msg2="";msg3="";msg4="";msg5="";
}
}
public void paint(Graphics g)
{
g.drawString(msg1,50,350);
g.drawString(msg2,50,370);
g.drawString(msg3,50,390);
g.drawString(msg4,50,410);
g.drawString(msg5,50,450);
}
}