<legend id='RQS3B'><style id='RQS3B'><dir id='RQS3B'><q id='RQS3B'></q></dir></style></legend>

    1. <tfoot id='RQS3B'></tfoot>

        • <bdo id='RQS3B'></bdo><ul id='RQS3B'></ul>

        <i id='RQS3B'><tr id='RQS3B'><dt id='RQS3B'><q id='RQS3B'><span id='RQS3B'><b id='RQS3B'><form id='RQS3B'><ins id='RQS3B'></ins><ul id='RQS3B'></ul><sub id='RQS3B'></sub></form><legend id='RQS3B'></legend><bdo id='RQS3B'><pre id='RQS3B'><center id='RQS3B'></center></pre></bdo></b><th id='RQS3B'></th></span></q></dt></tr></i><div id='RQS3B'><tfoot id='RQS3B'></tfoot><dl id='RQS3B'><fieldset id='RQS3B'></fieldset></dl></div>

        <small id='RQS3B'></small><noframes id='RQS3B'>

        JavaFX 创建警报并获得结果

        时间:2023-06-27
        • <small id='OEco6'></small><noframes id='OEco6'>

            <legend id='OEco6'><style id='OEco6'><dir id='OEco6'><q id='OEco6'></q></dir></style></legend>
              <bdo id='OEco6'></bdo><ul id='OEco6'></ul>

                • <i id='OEco6'><tr id='OEco6'><dt id='OEco6'><q id='OEco6'><span id='OEco6'><b id='OEco6'><form id='OEco6'><ins id='OEco6'></ins><ul id='OEco6'></ul><sub id='OEco6'></sub></form><legend id='OEco6'></legend><bdo id='OEco6'><pre id='OEco6'><center id='OEco6'></center></pre></bdo></b><th id='OEco6'></th></span></q></dt></tr></i><div id='OEco6'><tfoot id='OEco6'></tfoot><dl id='OEco6'><fieldset id='OEco6'></fieldset></dl></div>
                  <tfoot id='OEco6'></tfoot>
                    <tbody id='OEco6'></tbody>
                  本文介绍了JavaFX 创建警报并获得结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  对于我的 CS 课程,他们要求我们使用 JavaFX 警报.我可以发出警报,但是如何获取单击了哪个按钮?获取这些数据的最佳方法是什么?

                  For my CS class they require us to use JavaFX alerts. I can make an alert appear, but how do I get what button was clicked? What would be the best way to go about getting this data?

                  如果可能的话,我想让它有一个下拉面板,当用户选择和选项时,警报会关闭并打印用户选择的内容.

                  Also if possible, I'd like to make it have a drop down panel and when the user selects and option the alert closes and prints what the user selected.

                  这是我拥有的一些示例代码.当我单击其中一个按钮时,它只会关闭对话框.

                  Here's some example code that I have. When I click one of the buttons, it just closes the dialog.

                  Alert a = new Alert(AlertType.NONE, "Promote pawn to:", new ButtonType("Queen"), new ButtonType("Rook"));
                  a.setTitle("Title");
                  a.setHeaderText("My header text");
                  a.setResizable(true);
                  a.setContentText("Content text");
                  a.showAndWait();
                  

                  谢谢,

                  推荐答案

                  你可以做

                  ButtonType queen = new ButtonType("Queen");
                  ButtonType rook = new ButtonType("Rook");
                  Alert a = new Alert(AlertType.NONE, "Promote pawn to:", queen, rook);
                  a.setTitle("Title");
                  a.setHeaderText("My header text");
                  a.setResizable(true);
                  a.setContentText("Content text");
                  a.showAndWait().ifPresent(response -> {
                      if (response == queen) {
                          // promote to queen...
                      } else if (response == rook) {
                          // promote to rook...
                      }
                  });
                  

                  这篇关于JavaFX 创建警报并获得结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何制作“打开方式"对话框? 下一篇:Android-显示自定义对话框

                  相关文章

                  <small id='wX5zv'></small><noframes id='wX5zv'>

                    <tfoot id='wX5zv'></tfoot>

                    • <bdo id='wX5zv'></bdo><ul id='wX5zv'></ul>

                  1. <legend id='wX5zv'><style id='wX5zv'><dir id='wX5zv'><q id='wX5zv'></q></dir></style></legend>

                      <i id='wX5zv'><tr id='wX5zv'><dt id='wX5zv'><q id='wX5zv'><span id='wX5zv'><b id='wX5zv'><form id='wX5zv'><ins id='wX5zv'></ins><ul id='wX5zv'></ul><sub id='wX5zv'></sub></form><legend id='wX5zv'></legend><bdo id='wX5zv'><pre id='wX5zv'><center id='wX5zv'></center></pre></bdo></b><th id='wX5zv'></th></span></q></dt></tr></i><div id='wX5zv'><tfoot id='wX5zv'></tfoot><dl id='wX5zv'><fieldset id='wX5zv'></fieldset></dl></div>