Active Visual Scaffolding by Charles Kelemen and Eugene Turk
Some of the infrastructure code follows:
import java.awt.*;
import javax.swing.*;
....
public class ArrayGUI extends JFrame implements MouseListener {
boolean inAnApplet = true, frozen = false;
JButton highlightedIndex;
JPanel arrayPanel;
....
public ArrayGUI() {
Container contentPane = getContentPane();
JPanel column = new JPanel();
column.setLayout(new BoxLayout(column, BoxLayout.Y_AXIS));
.....
JScrollPane arrayScroller = new JScrollPane(arrayPanel);
column.add(arrayScroller);
....
JSlider speedSlider = new JSlider(JSlider.HORIZONTAL, 0, 100,
INITIAL_RATE);
speedSlider.addChangeListener(new SliderListener());
speedSlider.setMajorTickSpacing(10);
speedSlider.setPaintTicks(true);
.....
class SliderListener implements ChangeListener {
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
if (source.getValueIsAdjusting()) {
int fps = (int)source.getValue();
if (fps == 0) {
delay = 1000;
} else {
delay = 1000 / fps;
}
}
}
}
To pvwtalk14