GUI.java
3.93 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
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
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import javax.swing.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.StringReader;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.List;
import java.util.Vector;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
public class GUI extends JFrame {
JTabbedPane tab = new JTabbedPane();
public GUI(List<String> q) {
super("CESCO");
tab.addTab("png", new PngPane());
tab.addTab("gif", new GifPane());
tab.addTab("jpg", new JpgPane());
tab.addTab("table", new createTable(q));
add(tab);
setSize(800, 500); // 윈도우의 크기 가로x세로
setVisible(true); // 창을 보여줄떄 true, 숨길때 false
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // x 버튼을 눌렀을때 종료
}
// public static void main(String args[]) {
// new GUI();
// }
}
class PngPane extends JPanel {
public PngPane() {
super();
ImageIcon image = new ImageIcon("data/model.png");
JLabel label = new JLabel("", image, JLabel.CENTER);
setLayout(new BorderLayout());
add(label, BorderLayout.CENTER);
}
}
class GifPane extends JPanel {
public GifPane() {
super();
ImageIcon image = new ImageIcon("data/model.gif");
JLabel label = new JLabel("", image, JLabel.CENTER);
setLayout(new BorderLayout());
add(label, BorderLayout.CENTER);
}
}
class JpgPane extends JPanel {
public JpgPane() {
super();
ImageIcon image = new ImageIcon("data/model.jpg");
JLabel label = new JLabel("", image, JLabel.CENTER);
setLayout(new BorderLayout());
add(label, BorderLayout.CENTER);
}
}
class createTable extends JPanel {
public createTable(List<String> data) { //constructor : display table
getTableModel(data);
}
private DefaultTableModel getTableModel(List<String> data) {
String column_n[]={"ip","app","device","os","channel","is_attributed","click_time",
"avg_valid_click_count","click_time_delta","count_click_in_tenmin"};
Object tabledata[][]={};
DefaultTableModel model = new DefaultTableModel(tabledata,column_n);
JTable jtable = new JTable(model);
JScrollPane jScollPane = new JScrollPane(jtable);
add(jScollPane);
try {
for(int i =0; i<data.size();i++){
BufferedReader reader = getFileReader(data.get(i));
String line = reader.readLine();
line = line.replace("\"", "");
line = line.replace("_", "");
//line = line.replace("\\{","");
line = line.replaceAll("\\{|\\}","");
line = line.replaceAll("\\w+:", "");
//System.out.println(line);
Object [] temp= line.split(",");
model.addRow(temp);
reader.close();
}
} catch (Exception e) {
System.out.println(e);
}
return model;
}
private BufferedReader getFileReader(String data) {
BufferedReader reader = new BufferedReader(new StringReader(data));
// In your real application the data would come from a file
//Reader reader = new BufferedReader( new FileReader(...) );
return reader;
}
}