-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdetails.java
More file actions
57 lines (53 loc) · 1.01 KB
/
details.java
File metadata and controls
57 lines (53 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
import java.awt.*;
import java.awt.event.*;
public class details extends Frame implements ActionListener
{
Button b1=new Button("A");
Button b2=new Button("B");
String msg=" ";
//int mX=0,mY=0;
public details()
{
setLayout(new FlowLayout());
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
setBackground(Color.pink);
MyWindowAdapter adapter=new MyWindowAdapter();
addWindowListener(adapter);
}
public void actionPerformed(ActionEvent a1)
{
String s1;
s1=a1.getActionCommand();
if(s1.equals("A"))
{
msg="Name:Shrutika Shaw Course: B.Sc. Computer Science Roll No.: 2019345 College:SRCASW";
repaint();
}
else if(s1.equals("B"))
{
msg="CGPA: 9.5";
repaint();
}
}
public void paint(Graphics g)
{
g.drawString(msg,500,500);
}
public static void main(String args[])
{
details k1=new details();
k1.setSize(300, 200);
k1.setTitle("Frame Window Mouse events");
k1.setVisible(true);
}
}
class MyWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}