-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.java
88 lines (54 loc) · 2.48 KB
/
gui.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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class gui extends JFrame implements ActionListener {
weatherHub weatherHub = new weatherHub();
public gui() {
super("Weather Hub");
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
//add a new panel to the frame
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(2, 1));
//add a new button to the panel
JButton button = new JButton("Reload");
panel.add(button);
java.awt.Container pane = getContentPane();
pane.add(panel);
setVisible(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//create weatherHub.countWeatherStations() tables with 24 rows and 6 columns
//each table will have a name and location
//each table will have all the data for the day in it (24 rows and 6 columns)
//create a new panel to hold the tables
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(weatherHub.countWeatherStations(), 1));
//add the tables to the panel
for (int i = 0; i < weatherHub.countWeatherStations(); i++) {
//create a new table
String location = weatherHub.weatherHubStorageList.get(i).getLocation();
String name = weatherHub.weatherHubStorageList.get(i).getName();
double[][][][] data = weatherHub.weatherHubStorageList.get(i).getData();
JTable table = new JTable(24, 6);
table.setName(name + " " + location);
//add the data to the table
for (int j = 0; j < 24; j++) {
for (int k = 0; k < 6; k++) {
table.setValueAt(
data[weatherHub.weatherHubStorageList.get(i).getDayFromData(data)][j][k][0], j, k);
}
}
}
}
});
}
public static void main(String args[]) {
new gui();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}