How to show a prompt window on setting the cursor on a button with JavaFX? -


i want show prompt window while user set cursor on button. asking exactelly of how action on setting cursor on controller button, don't need butn.setcursor(cursor.hand); how can , thanks.

you can use button.setonmouseentered event show textinputdialog, wait user input , use it.

here small example, shows textinputdialog , prints data entered user.

import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.textinputdialog; import javafx.scene.layout.stackpane; import javafx.stage.stage;  import java.util.optional;  public class main extends application {      public static void main(string[] args) {         launch(args);     }      @override     public void start(stage primarystage) throws exception {         stackpane box = new stackpane();         button button = new button("hover on me !!!");         textinputdialog dialog = new textinputdialog("itachi");         dialog.setheadertext("text input dialog");         dialog.setcontenttext("please enter name:");         button.setonmouseentered(event -> {             if(!dialog.isshowing()) {                 optional<string> result = dialog.showandwait();                 result.ifpresent(name -> system.out.println("your name: " + name));             }         });         box.getchildren().add(button);         scene scene = new scene(box, 200, 200);         primarystage.setscene(scene);         primarystage.show();     } } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -