-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguifile.java
47 lines (42 loc) · 1.02 KB
/
guifile.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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
class gui1 implements ActionListener
{
JFrame jf;
JTextField jtf;
JLabel jl;
JButton jb;
gui1()
{
jf=new JFrame("write to a file");
jtf=new JTextField("enter the data to be written",20);
jl=new JLabel("press submit to write the contents");
jb=new JButton("submit");
FlowLayout f =new FlowLayout();
jf.setLayout(f);
jf.setSize(500,500);
jf.setVisible(true);
jf.add(jtf);
jf.add(jl);
jf.add(jb);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
String msg = jtf.getText();
try {
FileOutputStream fout = new FileOutputStream("output.txt");
fout.write(msg.getBytes());
;
} catch (Exception e) {
}
}
}
class guifile
{
public static void main(String a[])
{
gui1 g=new gui1();
}
}