JavaFX Tutorial - Java FlowPane(Orientation orientation) Constructor








Syntax

FlowPane(Orientation orientation) constructor from FlowPane has the following syntax.

public FlowPane(Orientation orientation)

Example

In the following code shows how to use FlowPane.FlowPane(Orientation orientation) constructor.

//from   w  w w.  ja va  2  s  . c o  m
import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);
  }

  @Override
  public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL);
    flowPane.setPrefWrapLength(210);                 
    Button btn = new Button();
         
    for(int i=0; i<8; i++){
      btn = new Button("Button");
      btn.setPrefSize(100, 50);
      flowPane.getChildren().add(btn);
    }           
    Scene scene = new Scene(flowPane);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
}