-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticipantPage.java
More file actions
216 lines (184 loc) · 6.33 KB
/
ParticipantPage.java
File metadata and controls
216 lines (184 loc) · 6.33 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
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
package speedmatch;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
public class ParticipantPage extends JFrame {
protected Dating event;
private int dirchange;
private String dir;
public ParticipantPage(Dating evt, int dc, String dd) {
event = evt;
dirchange = dc;
dir = dd;
initGUI();
}
public void initGUI() {
JPanel panel = new JPanel(new GridBagLayout());
this.getContentPane().add(panel);
panel.setOpaque(false);
this.getContentPane().setBackground(new Color(255, 229, 204));
setExtendedState(JFrame.MAXIMIZED_BOTH);
// Title and Subtitle
JLabel title = new JLabel("SpeedMatch - Main Menu");
title.setForeground(new Color(250, 92, 92));
title.setFont(new Font("Arial", Font.BOLD, 40));
JLabel subtitle = new JLabel("Add Paricipants, add likes and perform matching");
subtitle.setForeground(new Color(250, 92, 92));
subtitle.setFont(new Font("Arial", Font.BOLD, 25));
// Seperator
JSeparator sep = new JSeparator();
sep.setPreferredSize(new Dimension(500, 20));
// Buttons to add participants or likes
JPanel actionPanel = new JPanel();
actionPanel.setOpaque(false);
JButton addP = new JButton("Add Participant");
actionPanel.add(addP);
JButton likes = new JButton("Add Likes");
actionPanel.add(likes);
JButton lexport = new JButton("Open Participant List");
actionPanel.add(lexport);
JButton match = new JButton("Match!");
actionPanel.add(match);
// Buttons to change page or exit
JPanel pagePanel = new JPanel();
pagePanel.setOpaque(false);
JButton back = new JButton("< Back");
pagePanel.add(back);
JButton save = new JButton("Save");
pagePanel.add(save);
JButton exit = new JButton("Exit");
pagePanel.add(exit);
// Action Listener
// add Participant
addP.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AddParticipant newPartPage = new AddParticipant(event, dirchange, dir);
newPartPage.initializeAddPart();
}
});
// likes
likes.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AddLikes newLikePage = new AddLikes(event);
newLikePage.initializeLikes();
}
});
// match
ActionListener lm = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (dirchange == 1) {
Matching.outputMatches(dir, event);
} else {
Matching.outputMatches(event);
}
}
};
match.addActionListener(lm);
// Export List
lexport.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
File f;
if (dirchange == 1) {
f = new File(dir + event.getName() + "_list.txt");
} else {
f = new File(Processing.getHomeDir() + event.getName() + "_list.txt");
}
Desktop.getDesktop().open(f);
} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(ParticipantPage.this, "Error: You have to add Participants first",
"ERROR", JOptionPane.ERROR_MESSAGE);
} catch (Exception e2) {
JOptionPane.showMessageDialog(ParticipantPage.this, "Error: You have to add Participants first",
"ERROR", JOptionPane.ERROR_MESSAGE);
}
}
});
// Action Listener for exit
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// setVisible(false);
dispose();
}
});
// Action Listener for back
back.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
MainDesign frame = new MainDesign();
}
});
// Action Listener for Save
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
if (dirchange == 0) {
Processing.saveDating(event);
} else {
Processing.saveDating(event, dir);
}
JOptionPane.showMessageDialog(ParticipantPage.this, "Saved successfully", "Success",
JOptionPane.INFORMATION_MESSAGE);
} catch (Exception ex) {
JOptionPane.showMessageDialog(ParticipantPage.this, ex.getMessage(), "ERROR",
JOptionPane.ERROR_MESSAGE);
}
}
});
// Adding
/*
* GridBagConstraints gbc = new GridBagConstraints(); gbc.fill =
* GridBagConstraints.HORIZONTAL; gbc.gridwidth = GridBagConstraints.RELATIVE;
*
* gbc.gridx = 0; gbc.gridy = 0; gbc.ipady = 20; gbc.anchor =
* GridBagConstraints.PAGE_START; panel.add(title, gbc);
*
* gbc.gridx = 0; gbc.gridy = 1; panel.add(subtitle, gbc);
*
* gbc.gridx = 0; gbc.gridy = 2; panel.add(sep, gbc);
*
* gbc.gridx = 0; gbc.gridy = 4; gbc.insets = new Insets(10,0,0,0);
* panel.add(actionPanel, gbc);
*
* gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 5; //gbc.anchor =
* GridBagConstraints.LAST_LINE_END; panel.add(pagePanel, gbc);
*
* this.pack();
*
* this.setVisible(true);
*/
panel.add(title, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.PAGE_START,
GridBagConstraints.CENTER, new Insets(20, 0, 10, 0), 0, 0));
panel.add(subtitle, new GridBagConstraints(1, 1, GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
GridBagConstraints.PAGE_START, GridBagConstraints.VERTICAL, new Insets(0, 0, 10, 0), 0, 0));
panel.add(sep, new GridBagConstraints(0, 2, GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
GridBagConstraints.PAGE_START, GridBagConstraints.VERTICAL, new Insets(0, 0, 30, 0), 0, 0));
panel.add(actionPanel, new GridBagConstraints(0, 3, GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(200, 0, 100, 0), 0, 0));
panel.add(pagePanel, new GridBagConstraints(0, 4, GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(130, 0, 50, 0), 0, 0));
this.pack();
this.setVisible(true);
}
public void initializeUi() {
this.pack();
this.setVisible(true);
this.setTitle("SpeedDating - MatchFinder");
this.setSize(1000, 900);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
// public static void main(String[] args) {
//
// ParticipantPage ppage = new ParticipantPage();
// ppage.pack();
// ppage.setVisible(true);
// ppage.setTitle("SpeedDating - MatchFinder");
// ppage.setSize(1000, 900);
// ppage.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//
// }
}