1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.tudelft.goal.ut2004.visualizer.gui.dialogs;
18
19 import java.awt.FlowLayout;
20 import java.awt.Frame;
21 import javax.swing.JButton;
22 import javax.swing.JDialog;
23 import javax.swing.JLabel;
24 import javax.swing.JSpinner;
25 import javax.swing.SpinnerNumberModel;
26
27 import nl.tudelft.goal.ut2004.visualizer.gui.action.PauseResumeAction;
28 import nl.tudelft.goal.ut2004.visualizer.gui.action.SetSpeedAction;
29 import nl.tudelft.goal.ut2004.visualizer.util.WindowPersistenceHelper;
30
31
32
33
34
35
36
37 public class ChangeGameSpeedDialog extends JDialog {
38
39 private JSpinner speedSelection;
40 private JLabel setSpeed;
41 private JButton pauseResume;
42
43
44
45 private WindowPersistenceHelper persistenceHelper;
46
47 public ChangeGameSpeedDialog(Frame parent) {
48 super(parent, false);
49 setTitle("Change Game Speed");
50
51 this.pauseResume = new JButton(new PauseResumeAction());
52
53 this.speedSelection = new JSpinner(
54
55 new SpinnerNumberModel(1, 0.1, 10.0, 0.1));
56 this.speedSelection
57 .setEditor(new JSpinner.NumberEditor(speedSelection));
58 this.setSpeed = new JLabel("Game Speed");
59
60 this.speedSelection
61 .addChangeListener(new SetSpeedAction(speedSelection));
62
63 setLayout(new FlowLayout());
64 add(pauseResume);
65 add(setSpeed);
66 add(speedSelection);
67
68 this.setSize(400, 75);
69
70 persistenceHelper = new WindowPersistenceHelper(this);
71 persistenceHelper.load();
72
73 }
74 }