So here's the problem.
I know this code creates an infinite loop, but that is actually what I want.
The idea is that by pressing a start button this infinite loop is activated and repeated every 5 seconds. This keeps on going until I press the stop button.
Offcourse when an infinite loop is set in motion, the applet doesn't respond to anything(like pressing the stop button)because it wants to finish the while loop first.
Is there anyway that I can make it possible to push the stop button while the infinite loop is set in motion?
Code:private void Button_Start_Time_LoopActionPerformed(java.awt.event.ActionEvent evt) {
loop=true;
while(loop==true){
... //the code here is not important for my problem
Thread.sleep(5 * 1000);
}
}
private void Button_Stop_Time_LoopActionPerformed(java.awt.event.ActionEvent evt) {
loop=false;
}

