Login Register






Introduction to Loops with Java filter_list
Author
Message
RE: Introduction to Loops with Java #3
(08-14-2016, 08:48 AM)BxxxxxD~~ Wrote: would you be able to help me with an issue I'm having with a loop in java?
The problem is that I want a button to be able to start an infinite loop, and then end the loop when the button is repressed.
But, because it is a loop that loops constantly, the program will freeze and the user will be unable to press the button again once it has been started.
The second part of the issues is that the button needs to be pressed again to stop the loop, however whenever the button is pressed the loop will start.

If you can help that would be great, but either way your tutorial is well layed out and pretty helpful.

Hey, Threads aren't in the scope of this ttutorial but the reason your GUI freezes is because you aren't using a separate Thread. Since a single thread runs the Java GUI, the infinite loop won't allow it to render the button. Hence create another Thread, put the while loop inside it.. Try it and then report back
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply





Messages In This Thread
Introduction to Loops with Java - by Ex094 - 08-14-2016, 08:26 AM
RE: Introduction to Loops with Java - by Ex094 - 08-14-2016, 08:56 AM
RE: Introduction to Loops with Java - by Mr.Kurd - 08-14-2016, 09:50 AM
RE: Introduction to Loops with Java - by typhoid - 08-14-2016, 11:21 AM
RE: Introduction to Loops with Java - by Ex094 - 08-14-2016, 11:24 AM
RE: Introduction to Loops with Java - by Nil - 08-14-2016, 05:04 PM
RE: Introduction to Loops with Java - by Inori - 08-14-2016, 08:35 PM
RE: Introduction to Loops with Java - by Ex094 - 08-15-2016, 03:07 AM
RE: Introduction to Loops with Java - by Inori - 08-15-2016, 04:38 AM