在这里,我想创建一个自定义对话框,其工作方式类似于Alert,具有漂亮的 UI;“showDialog.fxml”是一个DialogPane.
我尝试过JFXDialog,但它没有等待,也没有给我用户的选择。有什么办法可以得到好的result吗?提前致谢。
这是我的Alert实现:
primaryStage.setOnCloseRequest(event -> {\n Alert alert = new Alert(Alert.AlertType.CONFIRMATION);\n alert.setTitle("\xd0\x92\xd1\x8b\xd1\x85\xd0\xbe\xd0\xb4");\n alert.setHeaderText("Are you really want to exit ?");\n ButtonType yes = new ButtonType("Yes");\n ButtonType no = new ButtonType("No");\n alert.getButtonTypes().clear();\n alert.getButtonTypes().addAll(yes, no);\n\n Optional<ButtonType> option = alert.showAndWait();\n if (option.get() == yes) {\n System.exit(0);\n } else {\n alert.close();\n event.consume();\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n这是新的。
\n primaryStage.setOnCloseRequest(event -> {\n FXMLLoader loader = new FXMLLoader(getClass().getResource("/views/common/showDialog.fxml"));\n ShowDialogController controller = loader.getController();\n Dialog<JFXButton> dialog = …Run Code Online (Sandbox Code Playgroud) javafx ×1