forked from VenusTokyo/first-year-java-practicals
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButtonAB.java
More file actions
58 lines (46 loc) · 1.01 KB
/
ButtonAB.java
File metadata and controls
58 lines (46 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
57
58
import java.awt.*;
import java.awt.event.*;
public class ButtonAB extends Frame implements ActionListener
{
Button A,B;
Label details,cgpa;
public ButtonAB()
{
FlowLayout f=new FlowLayout(3);
setLayout(f);
A=new Button("A");
B=new Button("B");
A.addActionListener(this);
B.addActionListener(this);
add(A);
add(B);
details=new Label("Shrutika Shaw,CS,2019345,SRCASW");
cgpa=new Label("CGPA:8.27");
add(details);
add(cgpa);
setTitle("Details");
setSize(400,400);
setVisible(true);
setBackground(Color.yellow);
details.setVisible(false);
cgpa.setVisible(false);
}
public void actionPerformed(ActionEvent a)
{
String s=a.getActionCommand();
if(s.equals("A"))
{
details.setVisible(true);
cgpa.setVisible(false);
}
else if(s.equals("B"))
{
details.setVisible(false);
cgpa.setVisible(true);
}
}
public static void main(String args[])
{
new ButtonAB();
}
}