123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- import java.io.*;
- import java.util.*;
- import java.awt.*;
- import javax.swing.*;
- import javax.swing.event.*;
- import java.awt.event.*;
- import javax.swing.ImageIcon;
- public class Controls extends JPanel implements Observer
- {
- private Model model;
- private playSlider playback;
- private JButton play;
- private JButton rewind;
- private JButton reset;
- private JButton clear;
- // Bob the Builder this shit
- public Controls(Model model)
- {
- // Hook up this observer so that it will be notified when the model
- // changes.
- this.model = model;
- this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
- this.setPreferredSize(new Dimension(1280,75));
- this.setMinimumSize(new Dimension(320, 75));
- this.play = new JButton("Play");
- play.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
-
- }
- });
- this.rewind = new JButton("Rewind");
- rewind.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
-
- }
- });
- this.playback = new playSlider(0, 0, 0);
- playback.addChangeListener(new ChangeListener()
- {
- public void stateChanged(ChangeEvent e)
- {
- if (!playback.getSettingLen())
- {
- }
- }
- });
- this.playback.setPreferredSize(new Dimension(280, 75));
- this.reset = new JButton("End");
- reset.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- //playback.setValue(playback.getMaximum());
- }
- });
- this.clear = new JButton("Start");
- clear.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- //playback.setValue(playback.getMinimum());
- }
- });
- this.add(play);
- this.add(rewind);
- this.add(playback);
- this.add(clear);
- this.add(reset);
- model.addObserver(this);
- }
- public void update(Object observable)
- {
- int len = 0;
- if (len > 0)
- {
- playback.toggleSettingLen();
- playback.setMaximum(len);
- playback.toggleSettingLen();
- }
- revalidate();
- repaint();
- }
- }
- class playSlider extends JSlider
- {
- private boolean settingLen;
-
- public playSlider(int min, int max, int val)
- {
- super(min, max, val);
- this.settingLen = false;
- }
-
- public void toggleSettingLen()
- {
- this.settingLen = !settingLen;
- }
- public boolean getSettingLen()
- {
- return settingLen;
- }
- }
|