-
Notifications
You must be signed in to change notification settings - Fork 1
/
Display.java
142 lines (123 loc) · 4.09 KB
/
Display.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import static javax.swing.JOptionPane.showMessageDialog;
public class Display extends JFrame implements ActionListener
{
private JLabel displayheading;
private JTextArea output;
private JButton display,back;
Container con=null;
Display()
{
super("Display Record");
con = getContentPane();
con.setLayout(null);
Color lightBlue = new Color(0,255,255);
con.setBackground(lightBlue);
con.setSize(300,300);
con.setLayout(null);
con.setVisible(true);
Color blue = new Color(30,144,255);
Font font = new Font("Verdana", Font.BOLD, 16);
displayheading=new JLabel("The records are:");
displayheading.setBounds(200, 2, 700,150);
displayheading.setFont(font);
displayheading.setForeground(Color.BLACK);
output=new JTextArea();
output.setBounds(20, 150, 1200,400);
output.setFont(font);
output.setForeground(Color.BLACK);
output.setEditable(false);
display = new JButton("Display");
display.setBounds(400,600,150,40);
display.addActionListener(this);
display.setFont(font);
Color pul = new Color(0,0,255);
Border bored = BorderFactory.createLineBorder(pul,5);
display.setBorder(bored);
display.setForeground(Color.WHITE);
display.setBackground(blue);
back = new JButton("Go Back");
back.setBounds(600,600,150,40);
back.addActionListener(this);
back.setFont(font);
back.setBorder(bored);
back.setForeground(Color.WHITE);
back.setBackground(blue);
con.add(displayheading);
con.add(output);
con.add(display);
con.add(back);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==display)
{
try
{
String name = "", usn ="", sem = "", branch = "", cgpa= "", nob="", company="",ctc="",comments="", r;
File temp = new File("temp.txt");
Boolean createNewFile1 = temp.createNewFile();
BufferedWriter pw = new BufferedWriter(new FileWriter("temp.txt"));
String b = "NAME\t|USN\t|SEM\t|BRANCH\t|CGPA\t|NOB\t|COMPANY\t|CTC\t|COMMENTS";
pw.write(b);
pw.write("\n");
BufferedReader br = new BufferedReader(new FileReader("student.txt"));
while((r= br.readLine()) !=null)
{
String[] result = r.split("\\|");
name=result[0];
usn=result[1];
sem= result[2];
branch=result[3];
cgpa=result[4];
nob=result[5];
company=result[6];
ctc=result[7];
comments=result[8];
if(name.equals("999"))
break;
String bb = name + "\t|" + usn + "\t|" + sem + "\t|" + branch + "\t|" + cgpa + "\t|" + nob + "\t|" + company + "\t|" + ctc + "\t|" + comments;
pw.write(bb);
pw.write("\n");
}
br.close();
pw.close();
File file = new File("temp.txt");
BufferedReader br1 = new BufferedReader(new FileReader(file));
output.read(br1,null);
br1.close();
output.requestFocus();
file.delete();
}
catch(Exception e)
{
e.printStackTrace();
}
}
if(ae.getSource()==back)
{
try
{
this.dispose();
Home h=new Home();
h.setSize(2300,790);
h.setVisible(true);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
public static void main(String args[])
{
Display dis=new Display();
dis.setSize(2300,790);
dis.setVisible(true);
}
}