-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrefWindow.java
More file actions
90 lines (78 loc) · 1.96 KB
/
PrefWindow.java
File metadata and controls
90 lines (78 loc) · 1.96 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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.ArrayList;
/** Window that pops up when the user selects "Preferences" from the menubar.
*
* @author Gemma Smith <gemma.smith@tufts.edu>
* @version 1.0
* @since 2013-12-09
*/
public class PrefWindow extends JFrame implements ActionListener,
ItemListener
{
private JFrame window;
private Main main;
private JCheckBox mute;
private JCheckBox nightTime;
public PrefWindow(Main mn)
{
super("Preferences");
main = mn;
window = this;
setSize(200,100);
setLocation(300,300);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setOpaque(true);
panel.setBackground(Color.WHITE);
mute = new JCheckBox("Mute volume");
mute.addItemListener(this);
mute.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(mute);
nightTime = new JCheckBox("Nighttime Theme");
nightTime.addItemListener(this);
nightTime.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(nightTime);
MyButton done = new MyButton("Done", Color.BLACK, 12);
done.addActionListener(this);
done.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(done);
add(panel);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
}
public void itemStateChanged(ItemEvent e)
{
Object source = e.getItemSelectable();
if (e.getStateChange() == ItemEvent.SELECTED)
{
if (source == mute)
{
main.mute(true);
}
else if (source == nightTime)
{
main.nightTime(true);
}
}
if (e.getStateChange() == ItemEvent.DESELECTED)
{
if (source == mute)
{
main.mute(false);
}
else if (source == nightTime)
{
main.nightTime(false);
}
}
}
/** Listener: not used in current version.
*/
public void actionPerformed(ActionEvent e)
{
window.setVisible(false);
main.closeWindow();
}
}