Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I align my objects AND set spacing between each other? Programming in JavaFX and Java
    primarykey
    data
    text
    <p>I 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.</p> <p>I want to have (Centered in the screen of course):</p> <pre><code>My Title SubLabel Button1 Button2 Button3 BottomLabel </code></pre> <p>But it shows up as:</p> <pre><code>My Title SubLabel Button1 Button2 Button3 BottomLabel </code></pre> <p>If I settranslateX my vbox or top label, it moves the label, but also moves everything else with it.</p> <p>How can I get it to align correctly?</p> <p>Here is my pseudo-code:</p> <pre><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; } </code></pre> <p>Another Node I have in my program with the same issue:</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload