This is obviously a threading problem. What
you should do (more or less) is:
1. click start button
2. fork threads:
2.A. AWTThread (main): e.g. disable "Start" button
2.B. create your counting
thread (new, returns at once,
runs in the background)
2.C. create a thread that joins 2.B. and waits
for it to die. this thread will notify the
AWTThread (and thus causes the gui to switch
state: disabling/enabling buttons)
3. click stop button
3.A. the click happens in the AWTThread and sends
an interruption signal to 2.C which will
cause 2.B to be interrupted.
if you do any gui painting, be sure to use SwingUtilities.invokeLater or SwingUtilities.invokeAndWait unless you are 100% sure to be in the AWTThread. for heavy backend processes create another thread, so the AWTThread yon't be blocked, and freezes your UI.
For more information on interrupting threads:
http://www.javaspecialists.co.za/archive/Issue056.html cheers
Chantal