我一直在玩JavaFX,我非常喜欢它。但我似乎无法让我的内容在我想要的地方。即使我将Vbox放在CENTER上,并在TOP上放置了一个标签,它们仍然处于中心位置,几乎相互接触。
我想拥有(当然在屏幕中央):
My Title
SubLabel
Button1
Button2
Button3
BottomLabel但它显示为:
My Title
SubLabel
Button1
Button2
Button3
BottomLabel如果我将我的vbox或顶部标签设置为X,它会移动标签,但也会移动标签。
我怎样才能让它正确对齐?
这是我的伪代码:
private Node PreMenu()
{
Group group2 = new Group();
BorderPane pane = new BorderPane();
Text label = new Text("Please Choose a Option");
label.setFont(Font.font("Kozuka Gothic Pro", 30));
label.setEffect(addEffect(Color.web("#FF6600"), .85, 20));
label.setTextAlignment(TextAlignment.CENTER);
label.setTranslateY(-300); //This moves my label, but it also moves the vbox under it DOWN.
VBox vbox = new VBox();
Button option1= new Button("Firstbutton");
Button option2= new Button("Secondbutton");
Button option3= new Button("HelpButton");
option1.setEffect(addEffect(Color.web("#FF6600"), .8, 10));
option2.setEffect(addEffect(Color.web("#FF6600"), .8, 10));
option3.setEffect(addEffect(Color.web("#FF6600"), .8, 10));
option1.setTextAlignment(TextAlignment.CENTER);
option1.setMinWidth(400);
option2.setTextAlignment(TextAlignment.CENTER);
option2.setMinWidth(400);
option3.setTextAlignment(TextAlignment.CENTER);
option3.setMinWidth(400);
vbox.setSpacing(20);
vbox.getChildren().add(option1);
vbox.getChildren().add(option2);
vbox.getChildren().add(option3);
pane.setTop(label);
pane.setCenter(vbox);
group2.getChildren().add(pane);
return group2;
}另一个节点,我在我的程序中有同样的问题: