I have a problem I can not get a return value because i want use it in controller. How can I get a return value from checkbox after close the window. Because I need a return value in controller. Thanks
import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.stage.Modality; import javafx.stage.Stage; public class CheckBox { public static String display(String title, String message){ Stage window = new Stage(); String id = " "; window.initModality(Modality.APPLICATION_MODAL); window.setTitle(title); window.setMinWidth(250); Label label = new Label(); label.setText(message); Button yButton = new Button("Y"); Button nbButton = new Button("N"); yButton.setId("Y"); nbButton.setId("N"); yButton.setOnAction(e -> window.close()); nbButton.setOnAction(e -> window.close()); VBox layout = new VBox(10); layout.getChildren().addAll(label,yButton, nbButton); layout.setAlignment(Pos.CENTER); Scene scene = new Scene(layout); window.setScene(scene); window.showAndWait(); if(yButton.isPressed()) return yButton.getId(); else if(nbButton.isPressed()) return nbButton.getId(); return null; } }