<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 创建警报并获得结果

        JavaFX create alert and get result(JavaFX 创建警报并获得结果)
        • <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 创建警报并获得结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

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

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

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

                      • <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>