-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq14.java
More file actions
72 lines (72 loc) · 1.7 KB
/
Copy pathq14.java
File metadata and controls
72 lines (72 loc) · 1.7 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import javax.swing.*;
import java.util.*;
import java.io.*;
import java.awt.event.*;
import java.awt.*;
class B
{
B()
{
JFrame f=new JFrame("Add");
JButton b=new JButton("Save");
Label l1=new Label(" Name");
Label l2=new Label(" Contect");
Label l3=new Label(" City");
TextField t1=new TextField();
TextField t2=new TextField();
TextField t3=new TextField();
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
f.add(p1);
f.add(p2);
f.add(p3);
p1.setLayout(new BoxLayout(p1,BoxLayout.Y_AXIS));
p2.setLayout(new BoxLayout(p2,BoxLayout.Y_AXIS));
p3.setLayout(new FlowLayout(FlowLayout.CENTER));
p1.add(l1);
l1.setFont(new Font("serif",Font.BOLD,30));
p1.add(l2);
l2.setFont(new Font("serif",Font.BOLD,30));
p1.add(l3);
l3.setFont(new Font("serif",Font.BOLD,30));
p2.add(t1);
t1.setFont(new Font("serif",Font.BOLD,40));
p2.add(t2);
t2.setFont(new Font("serif",Font.BOLD,40));
p2.add(t3);
t3.setFont(new Font("serif",Font.BOLD,40));
p3.add(b);
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
PrintWriter pw=new PrintWriter(new FileWriter(new File("C:\\Users\\akash\\Documents\\55\\numbers.txt"),true));
pw.println(t1.getText());
pw.println(t2.getText());
pw.println(t3.getText());
JOptionPane.showMessageDialog(null,"Data Is Saved");
pw.close();
pw.flush();
t1.setText("");
t2.setText("");
t3.setText("");
}
catch(Exception e1)
{
System.out.println(e1.getMessage());
}
}
});
b.setFont(new Font("serif",Font.BOLD,30));
f.setSize(600,350);
f.setVisible(true);
f.setLayout(null);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
p1.setBounds(0,0,300,200);
p2.setBounds(300,0,300,200);
p3.setBounds(0,200,600,150);
}
}