-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwarning.java
68 lines (52 loc) · 1.22 KB
/
warning.java
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
//unsaved data warning frame
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class warning extends JFrame implements ActionListener
{
warning(String s)
{
super(s);
setLayout(new BorderLayout());
JPanel jp1 = new JPanel();
jp1.setLayout(null);
JLabel jl1 = new JLabel("DO YOU WANT TO SAVE DATA BEFORE EXITING?");
jp1.add(jl1);
jl1.setBounds(60,30,300,30);
JButton jb1 = new JButton("YES");
JButton jb2 = new JButton("NO");
JButton jb3 = new JButton("CANCEL");
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jb1.setBounds(80,100,75,20);
jb2.setBounds(160,100,75,20);
jb3.setBounds(240,100,80,20);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
add(jp1,BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent ae)
{
String msg = ae.getActionCommand();
if(msg.equals("YES"))
{
pad.save();
setVisible(false);
}
if(msg.equals("NO"))
{
pad.jt1.setText("");
setVisible(false);
}
if(msg.equals("CANCEL"))
{
setVisible(false);
}
}
public static void main(String args[])
{
warning f1 = new warning("");
}
}