How to wait for user's action in JavaFX (in the same stage) -


do know how wait user's input in loop? don't mean showandwait() method, because not opening new dialogue stage user. example, each round of loop should waiting user push button before going ahead next round.

how possible? many thanks!

update:

now came mind, work while(buttonnotpressed){} solution? mean while loop running in case crazy until user won't push button. or doest work somehow wait methods?

imagine session: user starts session handlestart() give user 5 questions, 1 after one. in every iteration, user can answer upcoming question , can save or submit answer handlesavebutton() process answer want, , go ahead next iteration. point is, iteration must stop, until save button hasn't been pressed.

don't that. fx toolkit, event-driven gui toolkit, implements loop purposes of rendering scene graph , processing user input each iteration.

just register listener button, , whatever need when button pressed:

button.setonaction(event -> {     // code here... }); 

if want action change, change state of variable each time action performed:

private int round = 0 ;  // ...  button.setonaction(event -> {     if (round < 5) {         system.out.println("round "+round);         system.out.println("user's input: "+textarea.gettext());         round++ ;     } }); 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -