forked from ranjansharma255/Java_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChoiceDemo.java
More file actions
56 lines (41 loc) · 1.01 KB
/
ChoiceDemo.java
File metadata and controls
56 lines (41 loc) · 1.01 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
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code = ChoiceDemo width = 300 height = 300 > </applet>*/
public class ChoiceDemo extends Applet implements ItemListener
{
TextField t;
Choice a,b;
String msg = " ";
public void init()
{
setLayout(new FlowLayout());
t = new TextField(30);
a = new Choice();
a.addItemhi("CSE");
a.addItemhi("CSIT");
a.addItemhi("MECH");
a.addItemhi("ECE");
b = new Choice();
b.addItem("1st Year");
b.addItem("2nd Year");
b.addItem("3rd Year");
b.addItem("4th Year");
a.addItemListener(this);
b.addItemListener(this);
add(new Label("This is MREC Student"));
add(new Label("Enter your Branch"));
add(a);
add(new Label("Enter the year"));
add(b);
add(t);
}
public void itemStateChanged(ItemEvent e)
{
t.setText("I am "+a.getSelectedItem()+" "+b.getSelectedItem()+"Student");
}
public void paint(Graphics g)
{
showStatus("MREC STUDENT DETAILS");
}
}