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

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

    1. javafx 制作一个按钮网格

      javafx make a grid of buttons(javafx 制作一个按钮网格)
    2. <legend id='2XDTS'><style id='2XDTS'><dir id='2XDTS'><q id='2XDTS'></q></dir></style></legend>

          <tfoot id='2XDTS'></tfoot>

          <small id='2XDTS'></small><noframes id='2XDTS'>

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

              <tbody id='2XDTS'></tbody>
            • <bdo id='2XDTS'></bdo><ul id='2XDTS'></ul>

              • 本文介绍了javafx 制作一个按钮网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想用特定数量的按钮制作一个网格.我知道需要多少按钮,因为我得到了行数和列数.

                I want to make a grid with a specific amount of buttons. I know how many buttons there are need to be because I get the number of rows and columns.

                我可以做一个循环,但我不知道如何将按钮放在彼此旁边和下方.
                其次,按钮需要一个Text和一个Id,text没问题,但是怎么给它们一个id呢?
                最后,也可能是最困难的,可能会出现很多行,因此滚动条应该可用.

                I could do a loop, but I don't know how you can place buttons next to eachother and underneath.
                Secondly, the buttons need a Text and an Id, text is no problem, but how do you give them an id?
                And at last, and probably most difficult, it can occur that there are a lot of rows, so that a scrollbar should be available.

                最后应该是这样的:

                推荐答案

                @Override
                public void start(Stage stage) {
                    GridPane grid = new GridPane();
                    grid.setPadding(new Insets(BUTTON_PADDING));
                    grid.setHgap(BUTTON_PADDING);
                    grid.setVgap(BUTTON_PADDING);
                
                    for (int r = 0; r < NUM_BUTTON_LINES; r++) {
                        for (int c = 0; c < BUTTONS_PER_LINE; c++) {
                            int number = NUM_BUTTON_LINES * r + c;
                            Button button = new Button(String.valueOf(number));
                            grid.add(button, c, r);
                        }
                    }
                
                    ScrollPane scrollPane = new ScrollPane(grid);
                
                    stage.setScene(new Scene(scrollPane));
                    stage.show();
                }
                

                这篇关于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 中的默认语言环境设置以使其保持一致?)

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

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

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

                          <tbody id='eNNaX'></tbody>
                          <legend id='eNNaX'><style id='eNNaX'><dir id='eNNaX'><q id='eNNaX'></q></dir></style></legend>