<bdo id='P0esT'></bdo><ul id='P0esT'></ul>

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

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

    <tfoot id='P0esT'></tfoot>

    1. JavaFX 创建警报并获得结果

      时间:2023-09-28

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

        <tbody id='Ivqfd'></tbody>
    2. <tfoot id='Ivqfd'></tfoot>

        • <legend id='Ivqfd'><style id='Ivqfd'><dir id='Ivqfd'><q id='Ivqfd'></q></dir></style></legend>

              <bdo id='Ivqfd'></bdo><ul id='Ivqfd'></ul>

                <i id='Ivqfd'><tr id='Ivqfd'><dt id='Ivqfd'><q id='Ivqfd'><span id='Ivqfd'><b id='Ivqfd'><form id='Ivqfd'><ins id='Ivqfd'></ins><ul id='Ivqfd'></ul><sub id='Ivqfd'></sub></form><legend id='Ivqfd'></legend><bdo id='Ivqfd'><pre id='Ivqfd'><center id='Ivqfd'></center></pre></bdo></b><th id='Ivqfd'></th></span></q></dt></tr></i><div id='Ivqfd'><tfoot id='Ivqfd'></tfoot><dl id='Ivqfd'><fieldset id='Ivqfd'></fieldset></dl></div>
                本文介绍了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 创建警报并获得结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                相关文章

                最新文章

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

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

                  1. <small id='JNdy1'></small><noframes id='JNdy1'>

                    <tfoot id='JNdy1'></tfoot>