【发布时间】:2017-05-17 05:36:01
【问题描述】:
当我使用以下代码在网格窗格中创建 2 个按钮时,它给了我 2 个大小不等的按钮。我该如何解决这个问题?
/**
* Set the appearance of buttons in the grid
*/
private void setButtonAppearance(Button button)
{
button.setAlignment(Pos.CENTER);
//button.setFont(font);
button.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
button.setMinSize(Double.MIN_VALUE, Double.MIN_VALUE);
// doesn't start with focus or stay focused
button.setFocusTraversable(false);
}
/**
* Create buttons to perform allocation and deallocation of events to venues
*/
private void addButtons()
{
allocateButton = new Button("Allocate Event");
deallocateButton = new Button("Deallocate Event");
//Set appearance of buttons
setButtonAppearance(allocateButton);
setButtonAppearance(deallocateButton);
gridPane.add(allocateButton, 5, 30, 10, 1);
gridPane.add(deallocateButton, columns-15, 30, 10, 1);
}
问候!
【问题讨论】:
-
为什么不用前缀宽度?