-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWW.java
194 lines (168 loc) · 4.5 KB
/
MainWW.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
package soundPlayer;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.util.*;
public class MainWW extends JFrame implements ActionListener
{
//gui stuff
private JTextArea textA;
private JRadioButton fiveR;
private JTextArea textArea;
private JFrame help,about;
private JRadioButton tenR;
private JRadioButton custR;
private JTextField custV;
private JLabel fiveL ;
private JLabel tenL;
private JButton startB;
private JFrame trackList;
//fc stuff
private JMenuBar menuBar;
private JMenu menu;
private JMenuItem menuItem;
private JPopupMenu popmenu;
private JFileChooser fc;
//constraints
final static boolean shouldFill = true;
final static boolean shouldWeightX = true;
final static boolean RIGHT_TO_LEFT = false;
//non gui stuff
private Database db;
public MainWW()
{
JFrame frame = new JFrame();
Container pane = getContentPane();
db = new Database();
textA = new JTextArea("Welcome \nto the \nQuiztastic \nMusic Quiz \nGame");
fiveR = new JRadioButton();
tenR = new JRadioButton();
custR = new JRadioButton();
custV = new JTextField();
fiveL = new JLabel("5 Song Quiz");
tenL = new JLabel("10 Song Quiz");
startB = new JButton("Start");
menuBar = new JMenuBar();
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
pane.setLayout(layout);
//text area
//total label
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 1;
pane.add(textA,c);
//radio buttons
//fiveR;
ButtonGroup btnG = new ButtonGroup();
btnG.add(fiveR);
btnG.add(tenR);
btnG.add(custR);
c.gridx = 2;
pane.add(fiveR,c);
c.gridy = 1;
pane.add(tenR,c);
c.gridy = 2;
pane.add(custR,c);
//labels for radio buttons
c.gridx = 4;
c.gridy = 0;
pane.add(fiveL,c);
c.gridy = 1;
pane.add(tenL,c);
c.gridy = 2;
//pane.add(custV);
//add start button
c.gridy = 4;
c.gridx = 1;
pane.add(startB,c);
db = new Database();
//menubar setup
menu = new JMenu("File");
menuItem = new JMenuItem("Help");
menuItem.addActionListener(this);
menu.add(menuItem);
menu.addSeparator();
menuItem = new JMenuItem("About");
menuItem.addActionListener(this);
menu.add(menuItem);
menu.addSeparator();
menuItem = new JMenuItem("Exit");
menuItem.addActionListener(this);
menu.add(menuItem);
menuBar.add(menu);
frame.setJMenuBar(menuBar);
//about window
about = new JFrame();
JPanel aboutpanel = new JPanel();
textArea= new JTextArea("This program was made by: \n Pat Behrens & Jon McKeown \n for Mr. Clark's Apcs");
aboutpanel.add(textArea);
about.add(aboutpanel);
about.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
about.setSize(200,100);
about.setLocation(500,250);
// help window
help = new JFrame();
JPanel helppanel = new JPanel();
textArea= new JTextArea("Instructions: \n1) turn the music up! \n2) Select the button that corresponds to the song playing \n3) 10pts for every correct answer -5 for wrong answers ");
helppanel.add(textArea);
help.add(helppanel);
help.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
help.setSize(330,110);
help.setLocation(500,250);
//song menu
// trackList = new List(db.exportDB());
startB.addActionListener(this);
frame.add(pane);
frame.setSize(400, 400);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setLocation(100, 50);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
JButton btn = (JButton) e.getSource();
// File[] file = fc.getSelectedFiles();
if(btn == startB)
{
//get stuff from radio buttons here
//create an array list from teh database
//add in stuff to parse radio buttons or to make it easy just have a text field
Queue<ArrayList<MP3>> sets = new LinkedList<ArrayList<MP3>>();
sets = db.getSongs(10);
System.out.println("//////////////////////");
System.out.println(sets);
Game newGame = new Game(sets);
}
if (e.getActionCommand().equals("About"))
{
about.setVisible(true);
}
else if (e.getActionCommand().equals("Exit"))
{
System.exit(0);
}
else if (e.getActionCommand().equals("Help"))
{
help.setVisible(true);
}
}
public static void main(String[] args)
{
JFrame frame = new MainWW();
}
}
//class MyFilter extends javax.swing.filechooser.FileFilter
//{
// public boolean accept(File file) {
// String filename = file.getName();
// return filename.endsWith(".mp3");
// }
//
// public String getDescription() {
// return "*.mp3";
// }
//}