为此;我想要“连续”按钮开始rollthedice()和“停止”按钮来停止它,但是当我再次点击“连续”按钮时,我希望它再次开始rollthedice(),来回你能告诉我使用ScheduleThreadPoolExecutor的正确语法吗?
scheduler = new ScheduledThreadPoolExecutor(1);
ScheduledFuture now = null;
Runnable runner = new Runnable(){
public void run()
{
rollthedice();
}
};
if(e.getSource()==continuous)
{
now = scheduler.scheduleAtFixedRate(runner, 0, 500, TimeUnit.MILLISECONDS);
}
if(e.getSource()==stop)
{
now.cancel(true);
}
你试过谷歌搜索... – Joel
你能澄清一下你是什么意思的“点击连续按钮”?它是用户生成事件吗?你是怎样做的? – Arham
它的JFrame图形用户界面与按钮“停止”和“连续”此代码是在actionPerformed – JRowan