String str;
int fps = 0;
//How many milliseconds between frames?
str = getParameter("fps");
try {
if (str != null) {
fps = Integer.parseInt(str);
}
} catch (Exception e) {}
int delay = (fps > 0) ? (1000 / fps) : 100;
//Set up a timer that calls this object's action handler.
timer = new Timer(delay, this);
timer.setInitialDelay(0);
timer.setCoalesce(true);
label = new JLabel("Frame ", JLabel.CENTER);
label.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (frozen) {
frozen = false;
startAnimation();
} else {
frozen = true;
stopAnimation();
}
}
});
getContentPane().add(label, BorderLayout.CENTER);