使用JavaFX的GridPane
容器,如何设置一个按钮(或其他任何东西)水平扩展,直到它填满所有指定的单元格?
我使用以下行将按钮添加到GridPane:
grid.add(button, 3, 0, 3, 1);
但按钮的宽度与文本一样宽,约为2.5个单元格。我希望它完全占据所有3个指定的单元格。
答案 0 :(得分:3)
你可以做到
// allow button to grow:
button.setMaxWidth(Double.MAX_VALUE);
// ask GridPane to make button fill it's cells:
GridPane.setFillWidth(button, true);