Results 1 to 2 of 2
Thread: Stopping a looped method
- 09-26-2011, 12:43 AM #1
Stopping a looped method
I have a button that I want to "toggle". The button activates a looping method. I want to be able to stop the loop with the same button, or a different button if needed. For some reason the button freezes?
Java Code:public void start() { //some code(); start(); }Last edited by TyCox94; 09-26-2011 at 12:45 AM.
- 09-26-2011, 12:50 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,604
- Rep Power
- 5
Re: Stopping a looped method
Swing is single threaded: start a long task within the single thread (eg the EDT) - eg with the click of a button through an ActionListener - and it will lock up the user interface until said task is complete. Use a Thread, SwingWorker, or SwingTimer to do the work in parallel to the EDT. Google these for more information on each.
Similar Threads
-
stopping the thread
By kailash in forum Threads and SynchronizationReplies: 2Last Post: 02-06-2011, 01:21 PM -
Stopping threads
By phil128 in forum Threads and SynchronizationReplies: 2Last Post: 01-06-2011, 03:38 PM -
Stopping a thread
By userj2ee in forum New To JavaReplies: 3Last Post: 08-13-2010, 07:57 PM -
Stopping a .swf with java
By ercarls in forum New To JavaReplies: 2Last Post: 04-14-2010, 06:33 PM -
Looped repaint of display area
By gligor_kot in forum Java 2DReplies: 3Last Post: 07-28-2009, 12:53 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks