-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionsMenuGUI_V2.java
319 lines (263 loc) · 9.67 KB
/
OptionsMenuGUI_V2.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
//implements OptionsMenuGUI
public class OptionsMenuGUI_V2 {
//initialize variables
private JFrame frame;
private JTextField textbar; // input text
//these will need to be placed next to their according headers
private JTextField ComposerTextField;
private JTextField PieceTextField;
private JTextField FilePathTextField;
private JLabel header;
//these are on the JPanel LabelPanel
private JLabel NumQuestions;
private JLabel SectionPiece;
private JLabel MovementLimit;
private JLabel ComposerLimit;
private JLabel PieceLimit;
private JLabel FilePathLabel;
//instead of buttons should use checkboxes/(singledots...) align next to according headers
private JButton SubmitButton;
private JButton BrowseButton;
private JButton NextPhaseButton;
private JButton QuitButton;
private String inputtext;
private JTextArea area; // display text
private JScrollPane scroller;
private JPanel LabelPanel;
private JPanel HeaderPanel;
private JPanel SouthPanel;
private JPanel panel2; //old probably remove
private JPanel NumQuestionPanel;
private JPanel SectionPanel;
private JPanel MovementPanel;
private JPanel ComposerPanel;
private JPanel PiecePanel;
private JPanel FilePathPanel;
private JCheckBox BeginningBox;
private JCheckBox MiddleBox;
private JCheckBox EndBox;
private JCheckBox RandBox;
private JCheckBox OneBox;
private JCheckBox TwoBox;
private JCheckBox ThreeBox;
private JCheckBox FourBox;
private JCheckBox AllBox;
private ButtonGroup NumQuestionsGroup;
private JRadioButton FiveButton;
private JRadioButton TenButton;
private JRadioButton TwentyButton;
private JRadioButton ThirtyButton;
private JRadioButton FiftyButton;
public static void main (String[] args){
OptionsMenuGUI_V2 gui = new OptionsMenuGUI_V2();
gui.setup();
}
public void setup() {
//sets up the GUI
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// changet the buttons... use one for browse, one for next phase..
BrowseButton = new JButton("Browse");
// button1.addActionListener(new diceListener());
//add these to a panel and put them in the south.
NextPhaseButton = new JButton("Next Phase");
NextPhaseButton.addActionListener(new PhaseListener());
QuitButton = new JButton("Quit");
QuitButton.addActionListener(new QuitListener());
SubmitButton = new JButton("Submit");
SubmitButton.addActionListener(new SubmitListener());
// PlaceHolder: limit Composers
// PlaceHolder: Prioritize Pieces (By Op. #)
// PlaceHolder: FilePath
header = new JLabel("Options"); //look at fonts/spacing/formatting
NumQuestions = new JLabel("Number of Questions: ");
SectionPiece = new JLabel("Section of Piece: ");
MovementLimit = new JLabel("Movements: ");
ComposerLimit = new JLabel("Limit Composers: ");
PieceLimit = new JLabel("Prioritze Pieces(Op. #): ");
FilePathLabel = new JLabel("Enter File Path: ");
//Abstract these out into individual inner classes so that when listeners are implemented
// they can be added as "this"
FiveButton = new JRadioButton("Five");
FiveButton.setSelected(true);
// FiveButton.setActionCommand("Five"); // add these for the next 4 when implementing listeners
TenButton = new JRadioButton("Ten");
TwentyButton = new JRadioButton("Twenty");
ThirtyButton = new JRadioButton("Thirty");
FiftyButton = new JRadioButton("Fifty");
NumQuestionsGroup = new ButtonGroup();
NumQuestionsGroup.add(FiveButton);
NumQuestionsGroup.add(TenButton);
NumQuestionsGroup.add(TwentyButton);
NumQuestionsGroup.add(ThirtyButton);
NumQuestionsGroup.add(FiftyButton);
BeginningBox = new JCheckBox("Beginning");
MiddleBox = new JCheckBox("Middle");
EndBox = new JCheckBox("End");
RandBox = new JCheckBox("Random");
OneBox = new JCheckBox("First");
TwoBox = new JCheckBox("Second");
ThreeBox = new JCheckBox("Third");
FourBox = new JCheckBox("Fourth");
AllBox = new JCheckBox("All");
// textbar = new JTextField(10);
// textbar.addActionListener(new textListener());
// create listeners for the next three fields,
// use them to display the text on the area field for now...
ComposerTextField = new JTextField(50);
PieceTextField = new JTextField(50);
FilePathTextField = new JTextField(50);
LabelPanel = new JPanel();
LabelPanel.setLayout(new BoxLayout(LabelPanel,BoxLayout.Y_AXIS));
panel2 = new JPanel();
panel2.setLayout(new BoxLayout(panel2,BoxLayout.Y_AXIS));
HeaderPanel = new JPanel();
SouthPanel = new JPanel();
// SouthPanel.setLayout(new BoxLayout(LabelPanel,BoxLayout.Y_AXIS));
NumQuestionPanel = new JPanel();
SectionPanel = new JPanel();
MovementPanel = new JPanel();
ComposerPanel = new JPanel();
PiecePanel = new JPanel();
FilePathPanel = new JPanel();
area = new JTextArea(10,100); // move this to the header, and use it as display directions.
area.setEditable(false);
scroller = new JScrollPane(area);
area.setLineWrap(true);
scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
// panel2.add(scroller);
// panel2.add(textbar);
SouthPanel.add(SubmitButton);
SouthPanel.add(NextPhaseButton);
SouthPanel.add(QuitButton);
//the next lines need to be on a fram added to the west. Boxlayout/Y-axis
//use with the coinciding checkboxes/textfields/buttons...
//also look at formatting to separate from the "Options" tag and spacing/fonts
// in between each of these add their according checkbox components
NumQuestionPanel.add(NumQuestions);
NumQuestionPanel.add(FiveButton);
NumQuestionPanel.add(TenButton);
NumQuestionPanel.add(TwentyButton);
NumQuestionPanel.add(ThirtyButton);
NumQuestionPanel.add(FiftyButton);
SectionPanel.add(SectionPiece);
SectionPanel.add(BeginningBox);
SectionPanel.add(MiddleBox);
SectionPanel.add(EndBox);
SectionPanel.add(RandBox);
MovementPanel.add(MovementLimit);
MovementPanel.add(OneBox);
MovementPanel.add(TwoBox);
MovementPanel.add(ThreeBox);
MovementPanel.add(FourBox);
MovementPanel.add(AllBox);
ComposerPanel.add(ComposerLimit);
ComposerPanel.add(ComposerTextField);
PiecePanel.add(PieceLimit);
PiecePanel.add(PieceTextField);
FilePathPanel.add(FilePathLabel);
FilePathPanel.add(FilePathTextField);
FilePathPanel.add(BrowseButton);
//LabelPanel = new labelPanel();
LabelPanel.add(NumQuestionPanel);
LabelPanel.add(SectionPanel);
LabelPanel.add(MovementPanel);
LabelPanel.add(ComposerPanel);
LabelPanel.add(PiecePanel);
LabelPanel.add(FilePathPanel);
HeaderPanel.add(header);
HeaderPanel.add(scroller);
// frame.getContentPane().add(BorderLayout.CENTER, panel);
// frame.getContentPane().add(BorderLayout.EAST, panel2);
frame.getContentPane().add(BorderLayout.NORTH, HeaderPanel);
frame.getContentPane().add(BorderLayout.CENTER, LabelPanel);
frame.getContentPane().add(BorderLayout.SOUTH, SouthPanel);
frame.setSize(1280,960);
frame.setVisible(true);
}
/*
class labelPanel extends JPanel {
//inner class
//adds the graphics on panel. this method is called when the PANEL is initiated. and when frame.repaint() is called
LabelPanel.add(NumQuestionPanel);
LabelPanel.add(SectionPanel);
LabelPanel.add(MovementPanel);
LabelPanel.add(ComposerPanel);
LabelPanel.add(PiecePanel);
LabelPanel.add(FilePathPanel);
}
*/
/*
class diceListener implements ActionListener {
//inner class
//what to do when roll dice button is clicked
public void actionPerformed(ActionEvent event) {
int die1 = (int) (Math.random()*6) +1;
int die2 = (int) (Math.random()*6) +1;
//put if statements here to choose which piece moves?
x = x - 75*(die1+die2);
//rolls two dice and adds the results, multiplies by approximate width of tile
//this causes the piece to animate, we can make it move tile by tile later
area.append(" Player One: you rolled "+ die1 + " and " + die2 + "\n");
frame.repaint(); //calls PaintComponent Method in inner class PANEL
}
}
*/
class PhaseListener implements ActionListener {
//inner class
//what to do when mortgage button is clicked
public void actionPerformed(ActionEvent event) {
area.append(" Phase button works: \n"); //test code
//textbar.requestFocus();
//Code here to mortgage/unmortgage properties?
}
}
class QuitListener implements ActionListener {
//inner class
//what to do when buy houses button is clicked
public void actionPerformed(ActionEvent event) {
area.append(" Quit button works: \n"); //test code
//textbar.requestFocus();
//code here to buy houses/hotels/
}
}
class SubmitListener implements ActionListener {
//inner class
//what to do when buy houses button is clicked
public void actionPerformed(ActionEvent event) {
area.append(" Submit button works, Should post all the options that are set \n"); //test code
//textbar.requestFocus();
//code here to buy houses/hotels/
}
}
/*
class textListener implements ActionListener {
//inner class
//what to do when enter is hit (saves text, puts it in the JTextArea)
public void actionPerformed(ActionEvent evt) {
inputtext = textbar.getText(); //change textbar to be the 3 different textbars.
area.append(inputtext + "\n");
textbar.setText("");
//something here to interpret the users answers?
}
}
*/
/*
class PANEL extends JPanel {
//inner class
//adds the graphics on panel. this method is called when the PANEL is initiated. and when frame.repaint() is called
public void paintComponent(Graphics g) {
Image image = new ImageIcon("blankboard.jpg").getImage();
g.drawImage(image,0,0,this);
g.setColor(Color.blue);
g.fillOval(x,y,20,20);
g.setColor(Color.green);
g.fillOval(x2+20,y2+20,20,20);
}
}
*/
}