-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.java
46 lines (36 loc) · 1018 Bytes
/
gui.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.FileInputStream;
import java.io.*;
class window implements ActionListener {
JFrame jf;
JTextField jtf;
JButton jb;
JLabel jl;
window() {
jf = new JFrame("Write to file");
jtf = new JTextField("Enter the data to be written",30);
jl = new JLabel("Please press Submit to write the contents");
jb = new JButton("Submit");
jf.setLayout(new FlowLayout());
jf.setSize(500,500);
jf.setVisible(true);
jf.add(jl);
jf.add(jtf);
jf.add(jb);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
String message = jtf.getText();
try {
FileOutputStream fout = new FileOutputStream("output.txt");
fout.write(message.getBytes());;
} catch (Exception e) {}
}
}
public class gui {
public static void main(String[] args) {
new window();
}
}