Reputation: 6776
Using JavaFX's GridPane
container, how can I set a button (or anything else) to expand horizontally until it fills all assigned cells?
I add the button to my GridPane using this line:
grid.add(button, 3, 0, 3, 1);
But the button is only as wide as its text, which is about 2.5 cells. I want it to entirely occupy all 3 assigned cells.
Upvotes: 0
Views: 2748
Reputation: 209684
You can do
// allow button to grow:
button.setMaxWidth(Double.MAX_VALUE);
// ask GridPane to make button fill it's cells:
GridPane.setFillWidth(button, true);
Upvotes: 6