这个问题正在扩展另一个我通过Stackoverflow(Update JLabel every X seconds from ArrayList<List> - Java)获得了帮助,使我的标签每X秒更新一次。无论如何...我现在想增加或降低计时器的速度,并让它通过文件遍历一遍。用按钮增加或减少摆动计时器速度?
我打印语句看起来像这样:(INT TM设定在300目前...)
private void printWords() {
final Timer timer = new Timer(tM, null);
ActionListener listener = new ActionListener() {
private Iterator<Word> w = words.iterator();
@Override
public void actionPerformed(ActionEvent e) {
if (w.hasNext()) {
_textField.setText(w.next().getName());
//Prints to Console just Fine...
//System.out.println(w.next().getName());
}
else {
timer.stop();
}
}
};
timer.addActionListener(listener);
bPlay.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
timer.start();
}
});
bPause.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
timer.stop();
}
});
}
我想要做的是增加或与其他几个按钮的降低速度,更快和较慢。
我该如何改变中间使用的定时器间隔?
bFaster.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tM = 100;
}
});
bSlower.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tM = 1000;
}
});
感谢您的任何想法。
你的, JF
,我发现这里的东西:http://stackoverflow.com/questions/6791647/androids-countdowntimer-increase-or-decrease-the-指出笔记我不能做这样的事情。任何人? – jasonflaherty