New to JavaFX. Confused. How can I align my objects correctly?
925633Mar 21 2012 — edited Mar 22 2012I have been playing around with JavaFX and I really like it. But I can't seem to get my content where I want it. Even if I place a vbox on the CENTER and a label on the TOP, they're still in the center and almost touching each other.
I want to have:
My Title
SubLabel
Button1
Button2
Button3
BottomLabel
But it shows up as:
My Title
SubLabel
Button1
Button2
Button3
BottomLabel
If I settranslateX my vbox or top label, it moves the label, but also moves everything else with it.
How can I get it to align correctly?
Here is my pseudo-code:
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;
}