java - What's the code behind showAndWait in JavaFX? -
i developed small javafx application deployed in android device. since, alert not yet supported in current version of javafxports, made own implementaion of dialog. problem is: i not know how implement showandwait functionality. can know idea?
here's code:
private static int status; public static int showconfirm(string message){ status = 0; black = new stackpane(); black.setstyle("-fx-background-color: black; -fx-opacity: 0.7;"); black.setprefsize(main.width, main.height); label label = new label(message); label.setstyle("-fx-font-size: 22px;"); label.setwraptext(true); button okbtn = new button("ok"); okbtn.getstyleclass().add("terminal-button"); okbtn.setprefwidth(120); okbtn.setonaction(new eventhandler<actionevent>(){ @override public void handle(actionevent event) { status = 1; dialog.hide(); } }); button cancelbtn = new button("cancel"); cancelbtn.getstyleclass().add("terminal-button"); cancelbtn.setprefwidth(120); cancelbtn.setonaction(new eventhandler<actionevent>(){ @override public void handle(actionevent event) { status = -1; dialog.hide(); } }); hbox btncontainer = new hbox(10); btncontainer.setalignment(pos.center_right); btncontainer.getchildren().addall(okbtn,cancelbtn); vbox root = new vbox(30); root.setstyle("-fx-background-color: white;"); root.setpadding(new insets(20)); root.setprefwidth(main.width - 200); root.getchildren().addall(label,btncontainer); group container = new group(); container.getchildren().add(root); main.page.getchildren().add(black); main.page.getchildren().add(container); return status; }
Comments
Post a Comment