StackPane
使用
insets
让(管理的)孩子下岗。
Region
默认情况下不会这样做。因此,您需要覆盖
layoutChildren
用这些东西
插图
例如:
@Override
protected void layoutChildren() {
Insets insets = getInsets();
double top = insets.getTop(),
left = insets.getLeft(),
width = getWidth() - left - insets.getRight(),
height = getHeight() - top - insets.getBottom();
// layout all managed children (there's only rootPane in this case)
layoutInArea(rootPane,
left, top, // offset of layout area
width, height, // available size for content
0,
HPos.LEFT,
VPos.TOP);
}