JavaFX HBox set padding

Description

JavaFX HBox set padding

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class Main extends Application {
  @Override//  www.  ja  va 2  s.co  m
  public void start(Stage primaryStage) {
    // Create a border pane
    BorderPane pane = new BorderPane();

    // Place nodes in the pane
    pane.setTop(getHBox());

    Scene scene = new Scene(pane);
    primaryStage.setTitle("demo2s");
    primaryStage.setScene(scene);
    primaryStage.show();
  }

  private HBox getHBox() {
    HBox hBox = new HBox(15);
    hBox.setPadding(new Insets(15, 15, 15, 15));
    hBox.getChildren().add(new Button("HTML"));
    hBox.getChildren().add(new Button("CSS"));
    return hBox;
  }

  public static void main(String[] args) {
    launch(args);
  }
}



PreviousNext

Related