-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionsMenuGUI.java
296 lines (250 loc) · 8.91 KB
/
OptionsMenuGUI.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
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
//implements OptionsMenuGUI
public class OptionsMenuGUI {
//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;
private ButtonGroup FilePathGroup;
private JRadioButton ItunesButton;
private JRadioButton FolderButton;
private JRadioButton OtherButton;
public static void main (String[] args){
OptionsMenuGUI gui = new OptionsMenuGUI();
gui.setup();
}
public void setup() {
//sets up the GUI
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
LabelPanel = new JPanel();
LabelPanel.setLayout(new BoxLayout(LabelPanel,BoxLayout.Y_AXIS));
HeaderPanel = new HeaderComponents();
NumQuestionPanel = new NumberQuestionsComponents();
SectionPanel = new SectionComponents();
MovementPanel = new MovementComponents();
ComposerPanel = new ComposerComponents();
PiecePanel = new PiecePriorityComponents();
FilePathPanel = new FilePathComponents();
SouthPanel = new ButtonComponents();
//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
HeaderPanel.add(header);
HeaderPanel.add(scroller);
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(ItunesButton);
FilePathPanel.add(FolderButton);
FilePathPanel.add(OtherButton);
//make a newline here. also make it so that when
// different buttons are pressed the textfield acts differently
FilePathPanel.add(FilePathLabel);
FilePathPanel.add(FilePathTextField);
FilePathPanel.add(BrowseButton);
SouthPanel.add(SubmitButton);
SouthPanel.add(NextPhaseButton);
SouthPanel.add(QuitButton);
LabelPanel.add(NumQuestionPanel);
LabelPanel.add(SectionPanel);
LabelPanel.add(MovementPanel);
LabelPanel.add(ComposerPanel);
LabelPanel.add(PiecePanel);
LabelPanel.add(FilePathPanel);
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 HeaderComponents extends JPanel {
HeaderComponents() {
header = new JLabel("Options"); //look at fonts/spacing/formatting
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);
}
}
class NumberQuestionsComponents extends JPanel {
NumberQuestionsComponents() {
NumQuestions = new JLabel("Number of Questions: ");
//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);
}
}
class SectionComponents extends JPanel {
SectionComponents() {
SectionPiece = new JLabel("Section of Piece: ");
BeginningBox = new JCheckBox("Beginning");
MiddleBox = new JCheckBox("Middle");
EndBox = new JCheckBox("End");
RandBox = new JCheckBox("Random");
}
}
class MovementComponents extends JPanel {
MovementComponents() {
MovementLimit = new JLabel("Movements: ");
OneBox = new JCheckBox("First");
TwoBox = new JCheckBox("Second");
ThreeBox = new JCheckBox("Third");
FourBox = new JCheckBox("Fourth");
AllBox = new JCheckBox("All");
}
}
class ComposerComponents extends JPanel {
ComposerComponents() {
ComposerLimit = new JLabel("Limit Composers: ");
ComposerTextField = new JTextField(50);
//textlistener
}
}
class PiecePriorityComponents extends JPanel {
PiecePriorityComponents() {
PieceLimit = new JLabel("Prioritze Pieces(Op. #): ");
PieceTextField = new JTextField(50);
//textlistener
}
}
class FilePathComponents extends JPanel {
FilePathComponents() {
ItunesButton = new JRadioButton("Itunes");
ItunesButton.setSelected(true);
// ItunesButton.setActionCommand("Itunes");
FolderButton = new JRadioButton("Folder");
OtherButton = new JRadioButton("Other");
FilePathGroup = new ButtonGroup();
FilePathGroup.add(ItunesButton);
FilePathGroup.add(FolderButton);
FilePathGroup.add(OtherButton);
FilePathLabel = new JLabel("Enter File Path: ");
FilePathTextField = new JTextField(50);
//textfieldlistener, for testing, when enter is pressed then display the text.
BrowseButton = new JButton("Browse");
BrowseButton.addActionListener(new BrowseListener());
}
}
class ButtonComponents extends JPanel {
ButtonComponents() {
SubmitButton = new JButton("Submit");
SubmitButton.addActionListener(new SubmitListener());
NextPhaseButton = new JButton("Next Phase");
NextPhaseButton.addActionListener(new PhaseListener());
QuitButton = new JButton("Quit");
QuitButton.addActionListener(new QuitListener());
}
}
class PhaseListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
area.append(" Phase button works: \n");
}
}
class QuitListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
area.append(" Quit button works: \n");
}
}
class SubmitListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
area.append(" Submit button works, Should post all the options that are set \n"); //test code
}
}
class BrowseListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
area.append(" Browse button works \n");
}
}
/*
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?
}
}
*/
}