java - Using a timer to auto click a button when it runs out? -


i have 2 buttons, 1 ignore , 1 fight crime. want give user 10 seconds make choice. if fail in 10 seconds, want ignore autoclick , execute code. how go doing this? have struggled timers working.

there javax.swing.timer class in java. execute events after time given when creating object of timer class.. in milliseconds.

and have provide actionlistener event.

       // javax.swing.timer(timeafterwhichexecutetheeventinmilliseconds, listenerfortheevent)        javax.swing.timer timer = new javax.swing.timer(10000, new actionlistener() {             @override             public void actionperformed(actionevent e) {                 your_button.doclick();             }         }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -