JavaFX Tutorial - Java VBox(double spacing) Constructor








Syntax

VBox(double spacing) constructor from VBox has the following syntax.

public VBox(double spacing)

Example

In the following code shows how to use VBox.VBox(double spacing) constructor.

/*from  ww  w  .  j a v  a  2 s  .  co  m*/
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
 
public class Main extends Application {

    @Override
    public void start(final Stage stage) {
        stage.setTitle("HTML");
        stage.setWidth(500);
        stage.setHeight(500);
        Scene scene = new Scene(new Group());
 
        VBox vbox = new VBox(8); // spacing = 8
        vbox.getChildren().addAll(new Button("Cut"), new Button("Copy"), new Button("Paste"));
        
        scene.setRoot(vbox);

        stage.setScene(scene);
        stage.show();
    }
 
    public static void main(String[] args) {
        launch(args);
    }
}