Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Change speed of timer during run

843785Feb 13 2009 — edited Feb 13 2009
H, I have the code:
int delay = 0; .
int period = 5; 
Timer timer = new Timer();
//...
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {	
Calcule();
SchimbaPeriod();
repaint();			
}
}, delay, period);
//...
public void SchimbaPeriod()
{period=period+r.nextInt(3) - 1;
if (period==3) period=4; 
if (period==21) period=20;
}
But that dosnt change speed of timer, probably because it takes period only when timer is initiated.
What would be the way to that?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 13 2009
Added on Feb 13 2009
2 comments
309 views