public void actionPerformed(ActionEvent e) { if (e.getSource().equals(pausePlay)) { if (pausePlay.getText().equals("Play")) { pausePlay.setText("Pause"); LifeSimulation.timer().start(); } else { pausePlay.setText("Play"); LifeSimulation.timer().stop(); } } }
public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int delay = 1000 * (int) source.getValue(); LifeSimulation.timer().setDelay(delay); } }