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);
}
});
JButton plus10Button = new JButton("plus 10");
plus10Button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
delta(ProgressBarPanel.this, 10);
}
});
buttons.add(plus10Button);
JButton minus10Button = new JButton("minus 10");
minus10Button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
delta(ProgressBarPanel.this, -10);
}
});
buttons.add(minus10Button);
JButton plus1Button = new JButton("plus 1");
plus1Button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
delta(ProgressBarPanel.this, 1);
}
});
buttons.add(plus1Button);
JButton minus1Button = new JButton("minus 1");
minus1Button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
delta(ProgressBarPanel.this, -1);
}
});
buttons.add(minus1Button);
JButton resetButton = new JButton("reset");
resetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
progressTimeline.cancel();
reset(ProgressBarPanel.this);
stopButton.setEnabled(false);
startButton.setEnabled(true);
}
});