-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeTable.java
257 lines (232 loc) · 9.85 KB
/
TimeTable.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package phoenix;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import java.awt.Color;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
*
* @author DELL
*/
public class TimeTable extends javax.swing.JFrame {
/**
* Creates new form TimeTable
*/
DisplayManager dm= new DisplayManager();
public TimeTable() {
initComponents();
}
public TimeTable(DisplayManager d) {
dm=d;
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
View = new javax.swing.JButton();
View.setForeground(new Color(0, 204, 255));
Export = new javax.swing.JButton();
Export.setForeground(new Color(0, 204, 255));
jScrollPane2 = new javax.swing.JScrollPane();
Table = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
jLabel1.setForeground(new Color(0, 204, 255));
jLabel1.setBackground(new Color(47, 79, 79));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("AUTOMATIC TIME TABLING SYSTEM");
setBackground(new java.awt.Color(0, 153, 255));
setForeground(new java.awt.Color(0, 153, 255));
View.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
View.setText("View Time Table");
View.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ViewActionPerformed(evt);
}
});
Export.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
Export.setText("Export Time Table");
Export.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ExportActionPerformed(evt);
}
});
Table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
}
));
jScrollPane2.setViewportView(Table);
jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
jLabel1.setText("TIME TABLE IS READY!!!");
use_filters = new JButton("USE FILTERS");
use_filters.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
use_filterActionPerformed(e);
}
});
use_filters.setFont(new Font("Times New Roman", Font.BOLD, 18));
use_filters.setForeground(new Color(0, 204, 255));
home = new JButton("HOME");
home.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
homeActionPerformed(e);
}
});
home.setForeground(new Color(0, 204, 255));
home.setFont(new Font("Times New Roman", Font.BOLD, 18));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
layout.setHorizontalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 659, Short.MAX_VALUE)
.addGroup(Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(home, GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(View)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(Export)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(use_filters)))
.addContainerGap())
.addGroup(Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 222, GroupLayout.PREFERRED_SIZE)
.addGap(245))))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(use_filters)
.addComponent(Export, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(View)
.addComponent(home))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)
.addContainerGap())
);
getContentPane().setLayout(layout);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void ViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ViewActionPerformed
// TODO add your handling code here:
if(evt.getSource()==View)
{
String s="C:/Users/ANJALI/Desktop/java_project/test.csv";
File f=new File(s);
try {
BufferedReader br = new BufferedReader(new FileReader(f));
String firstline=br.readLine().trim();
String[] columnName=firstline.split(",");
DefaultTableModel model = (DefaultTableModel)Table.getModel();
model.setColumnIdentifiers(columnName);
Object[] tableLines=br.lines().toArray();
for(int i=0;i<tableLines.length;i++)
{
String Line=tableLines[i].toString().trim();
String[] datarow=Line.split(",");
model.addRow(datarow);
}
} catch (Exception ex) {
Logger.getLogger(TimeTable.class.getName()).log(Level.SEVERE, null, ex);
}
}
// if(evt.getSource()==View)
// {
// try{
// FileReader fr = new FileReader("D:/Vaibhav.csv");
// BufferedReader br = new BufferedReader(fr);
// TextPane.read(br, null);
// br.close();
// TextPane.requestFocus();
// }
// catch(Exception e)
// {
// System.out.println(e.getMessage());
// }
// }
}//GEN-LAST:event_ViewActionPerformed
private void ExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExportActionPerformed
// TODO add your handling code here:
if(evt.getSource()==Export)
{
System.out.println("No Task Specified");
}
}//GEN-LAST:event_ExportActionPerformed
/**
* @param args the command line arguments
*/
private void homeActionPerformed(ActionEvent e) {
dm.load(dm);
this.setVisible(false);
}
private void use_filterActionPerformed(ActionEvent e) {
dm.setFilterScreen(dm);
this.setVisible(false);
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TimeTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TimeTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TimeTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TimeTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TimeTable().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
public javax.swing.JButton Export;
public javax.swing.JTable Table;
public javax.swing.JButton View;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane2;
private JButton use_filters;
private JButton home;
}