-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSVreader.java
80 lines (71 loc) · 2.12 KB
/
CSVreader.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
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.JFileChooser;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTable;
public class CSVreader extends JFrame {
private JPanel contentPane;
//public File file;
private JTable table;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
CSVreader frame = new CSVreader();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void drawTable(File file)
{
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBounds(10, 11, 706, 430);
contentPane.add(scrollPane);
CSVextract extract = new CSVextract(file);
try {
extract.readCSV(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
table = new JTable();
table.setBounds(810, 60, 31, 49);
scrollPane.add(table);
}
public CSVreader()
{
File file;
setVisible(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 854, 555);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JFileChooser fc = new JFileChooser("D:\\GraphPlottingSuite\\DataCSV\\");
fc.setFileFilter(new FileNameExtensionFilter("*.csv",".csv","csv","CSV",".CSV"));
int result = fc.showOpenDialog(this);
if (result == JFileChooser.OPEN_DIALOG) {
file = fc.getSelectedFile();
drawTable(file);
} else if (result == JFileChooser.CANCEL_OPTION) {
System.out.println("Cancel was selected");
}
fc.setBounds(0, 0, 761, 286);
//contentPane.add(fc);
//////////////
}
}