-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ2.java
58 lines (58 loc) · 1.46 KB
/
Q2.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
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Q2 extends Dialog implements ActionListener
{
Label l1;
Button b1,b2,b3;
MainMenu k;
Q2(MainMenu p,String tt,boolean rr)
{
super(p,tt,rr);
k=p;
l1= new Label("Do You want to save the Changes");
b1= new Button("Yes Save");
b2=new Button("Dont Save");
b3= new Button("Cancel");
setLayout(new FlowLayout());
add(l1);
add(b1);
add(b2);
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if(str.equals("Yes Save"))
{
try{
FileDialog f1= new FileDialog(this,"Save",FileDialog.SAVE);
f1.setVisible(true);
FileOutputStream f= new FileOutputStream(f1.getDirectory()+f1.getFile());
str= k.t1.getText();
byte b[]=str.getBytes();
int i;
for(i=0;i<b.length;i++)
{
f.write(b[i]);
}
f.close();
}
catch(Exception e1)
{
}
}
else if(str.equals("Dont Save"))
{
this.dispose();
// k.dispose();
}
else if(str.equals("Cancel"))
{
this.dispose();
}
}
}