swing - java: how to delay code in GUI -


i making programme in java school project. has form of interactive multiple-choice test.

i wanted perform in way action button creates event in (the order of code same listed):

1) randomly chooses object consist of several strings prepared list , prints on adequate text fields in gui

2) using proper method there delay created holds further code down below 1 minute. in time user should able check proper checkboxes gui must stay active.

3)when minute ends checked places read , further processed.

the thing unable create step number 2) delaying of code below. have tried function sleep() when sleep() whole gui freezes , user unable on it. have read function swing timer appropriate dont know how it. have seen examples in them timer along functions executed after time written in class actionlistener instead of action button. using netbeans 8.1

sorry bad explanation of problem, total beginner in java programming , count on :) cheers!

enter image description here

your problem comes how structured code. wrote single method.

split 2 methods. 1 set ui state (everything before "here need delay..."). second method takes below.

then, @ end of first method, create non-repeating timer 1 minute, add actionlistener calls second method. start timer. when timer has run course, call second method through action listener.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -