JavaFX VBox Layout

0

VBox Layout in JavaFX :

  • VBox layout all their children in one vertical column.
  • It is also a basic layout which is mostly used with combination with other layout.

Example using VBox layout :



Example :
package javafxtuts;


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 *
 * @author javafxtuts
 */
public class Javafxtuts extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        
        VBox root = new VBox();
        
        for (int i=1; i

Output :

Explanation of VBox layout code:

    • To use VBox Layout we create a reference of VBox AS

VBox root = new VBox();

    • Now root is our VBox layout. So using this we can place the UI controls in the layout As

root.getChildren().add(b);

Share.

Leave A Reply