Skip to content

Commit 4c1fedd

Browse files
committed
modified
1 parent a1ccca1 commit 4c1fedd

File tree

1 file changed

+51
-90
lines changed

1 file changed

+51
-90
lines changed

File_Sharing/hi.java

+51-90
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package file_sharing;
22

3+
34
/**
45
*
5-
*@author avsingh
6-
*
7-
* @author DakshGondaliya
8-
*/
6+
* @author avsingh
7+
*/
98

109

1110
import java.awt.TextField;
@@ -29,6 +28,10 @@
2928
import java.util.Scanner;
3029
import javax.swing.JTextField;
3130

31+
/**
32+
*
33+
* @author DakshGondaliya
34+
*/
3235
class Record
3336
{
3437
String filename;
@@ -55,15 +58,13 @@ public String toString()
5558

5659
}
5760

58-
public class hi extends javax.swing.JFrame
59-
{
61+
public class hi extends javax.swing.JFrame {
6062
ArrayList<Record> record = new ArrayList<Record>();
6163
String get_txt="";
6264
/**
6365
* Creates new form hi
6466
*/
65-
public hi()
66-
{
67+
public hi() {
6768
initComponents();
6869
this.search_txt_fil.setText("");
6970
}
@@ -75,8 +76,7 @@ public hi()
7576
*/
7677
@SuppressWarnings("unchecked")
7778
// <editor-fold defaultstate="collapsed" desc="Generated Code">
78-
private void initComponents()
79-
{
79+
private void initComponents() {
8080

8181
textArea1 = new java.awt.TextArea();
8282
search_txt_fil = new java.awt.TextField();
@@ -92,28 +92,23 @@ private void initComponents()
9292
search_txt_fil.setText("textField1");
9393

9494

95-
search_txt_fil.addActionListener(new java.awt.event.ActionListener()
96-
{
97-
public void actionPerformed(java.awt.event.ActionEvent evt)
98-
{
95+
search_txt_fil.addActionListener(new java.awt.event.ActionListener() {
96+
public void actionPerformed(java.awt.event.ActionEvent evt) {
9997

10098
get_txt = search_txt_fil.getText();
10199
search_txt_fil.setText(get_txt);
102100

103101
}
104102
});
105103
Search_txt.setText("search");
106-
Search_txt.addActionListener(new java.awt.event.ActionListener()
107-
{
108-
public void actionPerformed(java.awt.event.ActionEvent evt)
109-
{
104+
Search_txt.addActionListener(new java.awt.event.ActionListener() {
105+
public void actionPerformed(java.awt.event.ActionEvent evt) {
110106
get_txt = search_txt_fil.getText();
111107
System.out.println(get_txt+"-----?");
112108
// Search_txtActionPerformed(evt);
113109
Object obj [][]= new Object [1000][5];
114110
// ArrayList<String> array_list = new ArrayList<String>();
115-
try
116-
{
111+
try{
117112
FileInputStream fstream = new FileInputStream("text.txt");
118113
DataInputStream in = new DataInputStream(fstream);
119114
BufferedReader br = new BufferedReader(new InputStreamReader(in));
@@ -122,8 +117,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
122117
// ArrayList<Record> record = new ArrayList<Record>();
123118
int i=0;
124119

125-
while ((strLine = br.readLine()) != null)
126-
{
120+
while ((strLine = br.readLine()) != null){
127121

128122
String[] tokens = strLine.split(" ");
129123

@@ -146,8 +140,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
146140

147141
History_table.setModel(new javax.swing.table.DefaultTableModel(
148142
obj,
149-
new String []
150-
{
143+
new String [] {
151144
"File", "Date", "Time", "action","User"
152145
}
153146
));
@@ -188,23 +181,19 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
188181

189182
History_table.setModel(new javax.swing.table.DefaultTableModel(
190183
obj,
191-
new String []
192-
{
184+
new String [] {
193185
"File", "Date", "Time", "action","User"
194186
}
195187
));
196188
jScrollPane1.setViewportView(History_table);
197189

198190
Filter.setText("Filter");
199-
Filter.addActionListener(new java.awt.event.ActionListener()
200-
{
191+
Filter.addActionListener(new java.awt.event.ActionListener() {
201192
// private Object javax;
202-
public void actionPerformed(java.awt.event.ActionEvent evt)
203-
{
193+
public void actionPerformed(java.awt.event.ActionEvent evt) {
204194

205195
// FilterActionPerformed(evt);
206-
if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("name"))
207-
{
196+
if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("name")){
208197

209198
Collections.sort(record, new NameComparator());
210199
Object obj1 [][] = new Object[record.size()][5];
@@ -219,15 +208,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
219208

220209
History_table.setModel(new javax.swing.table.DefaultTableModel(
221210
obj1,
222-
new String []
223-
{
211+
new String [] {
224212
"File", "Date", "Time","Action","from"
225213
}
226214
));
227215
}
228216
// System.out.println("Fdsfs")
229-
else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("Date"))
230-
{
217+
else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("Date")){
231218
Collections.sort(record,new DateModifiedComparator());
232219
Object obj1 [][] = new Object[record.size()][5];
233220
for(int i=0;i<record.size();i++){
@@ -240,14 +227,12 @@ else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("Date")
240227
}
241228
History_table.setModel(new javax.swing.table.DefaultTableModel(
242229
obj1,
243-
new String []
244-
{
230+
new String [] {
245231
"File", "Date", "Time","Action","from"
246232
}
247233
));
248234
}
249-
else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("User"))
250-
{
235+
else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("User")){
251236
Collections.sort(record,new userNameComparator());
252237
Object obj1 [][] = new Object[record.size()][5];
253238
for(int i=0;i<record.size();i++){
@@ -260,8 +245,7 @@ else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("User")
260245
}
261246
History_table.setModel(new javax.swing.table.DefaultTableModel(
262247
obj1,
263-
new String []
264-
{
248+
new String [] {
265249
"File", "Date", "Time","Action","from"
266250
}
267251
));
@@ -272,10 +256,8 @@ else if(Filter_items.getItemAt(Filter_items.getSelectedIndex()).endsWith("User")
272256

273257

274258
Cancel_button.setText("Cancel");
275-
Cancel_button.addActionListener(new java.awt.event.ActionListener()
276-
{
277-
public void actionPerformed(java.awt.event.ActionEvent evt)
278-
{
259+
Cancel_button.addActionListener(new java.awt.event.ActionListener() {
260+
public void actionPerformed(java.awt.event.ActionEvent evt) {
279261
Cancel_buttonActionPerformed(evt);
280262
}
281263
});
@@ -320,56 +302,42 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
320302
pack();
321303
}// </editor-fold>
322304

323-
private void search_txt_filActionPerformed(java.awt.event.ActionEvent evt)
324-
{
305+
private void search_txt_filActionPerformed(java.awt.event.ActionEvent evt) {
325306
// TODO add your handling code here:
326307

327308
}
328309

329-
private void Cancel_buttonActionPerformed(java.awt.event.ActionEvent evt)
330-
{
310+
private void Cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {
331311
// TODO add your handling code here:
332312
this.dispose();
333313
}
334314

335315
/**
336316
* @param args the command line arguments
337317
*/
338-
public static void main(String args[])
339-
{
318+
public static void main(String args[]) {
340319

341-
try
342-
{
320+
try {
343321
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
344322
if ("Nimbus".equals(info.getName())) {
345323
javax.swing.UIManager.setLookAndFeel(info.getClassName());
346324
break;
347325
}
348326
}
349-
}
350-
catch (ClassNotFoundException ex)
351-
{
327+
} catch (ClassNotFoundException ex) {
352328
java.util.logging.Logger.getLogger(hi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
353-
}
354-
catch (InstantiationException ex)
355-
{
329+
} catch (InstantiationException ex) {
356330
java.util.logging.Logger.getLogger(hi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
357-
}
358-
catch (IllegalAccessException ex)
359-
{
331+
} catch (IllegalAccessException ex) {
360332
java.util.logging.Logger.getLogger(hi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
361-
}
362-
catch (javax.swing.UnsupportedLookAndFeelException ex)
363-
{
333+
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
364334
java.util.logging.Logger.getLogger(hi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
365335
}
366336
//</editor-fold>
367337

368338
/* Create and display the form */
369-
java.awt.EventQueue.invokeLater(new Runnable()
370-
{
371-
public void run()
372-
{
339+
java.awt.EventQueue.invokeLater(new Runnable() {
340+
public void run() {
373341
new hi().setVisible(true);
374342
}
375343
});
@@ -389,36 +357,29 @@ public void run()
389357

390358

391359

392-
class NameComparator implements Comparator<Record>
393-
{
394-
public int compare(Record e1, Record e2)
395-
{
396-
return e1.filename.compareToIgnoreCase(e2.filename);
397-
}
360+
class NameComparator implements Comparator<Record>{
361+
362+
public int compare(Record e1, Record e2){
363+
return e1.filename.compareToIgnoreCase(e2.filename);
364+
}
398365
}
399366

400-
class DateModifiedComparator implements Comparator<Record>
401-
{
367+
class DateModifiedComparator implements Comparator<Record>{
402368

403369
DateFormat f = new SimpleDateFormat("MM/dd/yyyy hh:mm a");
404370
@Override
405-
public int compare(Record o1, Record o2)
406-
{
371+
public int compare(Record o1, Record o2) {
407372
// TODO Auto-generated method stub
408-
try
409-
{
410-
return f.parse(o1.Date_Time).compareTo(f.parse(o2.Date_Time));
411-
}
412-
catch (ParseException e)
413-
{
414-
throw new IllegalArgumentException(e);
415-
}
373+
try {
374+
return f.parse(o1.Date_Time).compareTo(f.parse(o2.Date_Time));
375+
} catch (ParseException e) {
376+
throw new IllegalArgumentException(e);
377+
}
416378

417379
}
418380
}
419381

420-
class userNameComparator implements Comparator<Record>
421-
{
382+
class userNameComparator implements Comparator<Record>{
422383

423384
public int compare(Record e1, Record e2)
424385
{

0 commit comments

Comments
 (0)