spam - Java message sender brakes the rest of program -


ok, title said got small tool helps me , wanted add "sort of message spammer" when starts can't stop it.

here's code:

spamscripttogglebutton.additemlistener(new itemlistener() {         @override         public void itemstatechanged(itemevent ev) {             if (ev.getstatechange()==itemevent.selected) {                 = 3;             } else if(ev.getstatechange()==itemevent.deselected){                 = 1;             }         while(i > 2) {             robot.delay(40);             type("message "+i+" !");             i++;             }         }     }); 

my question how can make stop, clicking togglebutton doesn't help, , please keep in mind need count messages.

thanks, christian

the listener called on event dispatch thread https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html while busy can't else handle cancel button, or update screen.

any non trivial task run in thread of it's own.


Comments