this.add(new JScrollPane(bars), BorderLayout.CENTER);
JPanel buttons = new JPanel();
buttons.setLayout(new FlowLayout(FlowLayout.CENTER));
final Timeline progressTimeline = new Timeline(this);
@RunOnUIThread
class ProgressCallback extends TimelineCallbackAdapter {
@Override
public void onTimelinePulse(float durationFraction,
float timelinePosition) {
delta(ProgressBarPanel.this, 1);
}
}
progressTimeline.addCallback(new ProgressCallback());
progressTimeline.setDuration(2000);
this.startButton = new JButton("start");
this.startButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
progressTimeline.playLoop(RepeatBehavior.LOOP);
startButton.setEnabled(false);
stopButton.setEnabled(true);
}
});
this.stopButton = new JButton("stop");
this.stopButton.setEnabled(false);
this.stopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
progressTimeline.cancel();
stopButton.setEnabled(false);
startButton.setEnabled(true);
}
});