|
@@ -6,6 +6,7 @@ import javax.swing.*;
|
|
public class Controls extends JPanel implements Observer
|
|
public class Controls extends JPanel implements Observer
|
|
{
|
|
{
|
|
private Model model;
|
|
private Model model;
|
|
|
|
+ private JSlider playback;
|
|
|
|
|
|
// Bob the Builder this shit
|
|
// Bob the Builder this shit
|
|
public Controls(Model model, Handler handler)
|
|
public Controls(Model model, Handler handler)
|
|
@@ -13,17 +14,25 @@ public class Controls extends JPanel implements Observer
|
|
// Hook up this observer so that it will be notified when the model
|
|
// Hook up this observer so that it will be notified when the model
|
|
// changes.
|
|
// changes.
|
|
this.model = model;
|
|
this.model = model;
|
|
- this.setPreferredSize(new Dimension(300, 30));
|
|
|
|
|
|
+ this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
|
this.setPreferredSize(new Dimension(1280,75));
|
|
this.setPreferredSize(new Dimension(1280,75));
|
|
this.setMinimumSize(new Dimension(320, 75));
|
|
this.setMinimumSize(new Dimension(320, 75));
|
|
|
|
+ this.playback = new JSlider(1, model.getThingies().size(), model.getThingies().size());
|
|
|
|
+ this.playback.addChangeListener(new ChangeListener()
|
|
|
|
+ {
|
|
|
|
+ public void stateChanged(ChangeEvent e)
|
|
|
|
+ {
|
|
|
|
+ model.changeThingy(playback.getValue() - 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.playback.setPreferredSize(new Dimension(280, 75));
|
|
|
|
+ this.add(playback);
|
|
model.addObserver(this);
|
|
model.addObserver(this);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Update with data from the model.
|
|
|
|
- */
|
|
|
|
public void update(Object observable)
|
|
public void update(Object observable)
|
|
{
|
|
{
|
|
|
|
+ this.playback.setMaximum(model.getThingies().size());
|
|
this.setBackground(model.controlColour);
|
|
this.setBackground(model.controlColour);
|
|
revalidate();
|
|
revalidate();
|
|
repaint();
|
|
repaint();
|