<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 制作一个按钮网格

      时间:2024-08-24
    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 制作一个按钮网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:网格中的 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'>

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