Example usage for javafx.scene.layout HBox HBox

List of usage examples for javafx.scene.layout HBox HBox

Introduction

In this page you can find the example usage for javafx.scene.layout HBox HBox.

Prototype

public HBox() 

Source Link

Document

Creates an HBox layout with spacing = 0.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    HBox root = new HBox();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);//  w  w w  .j a  v a 2 s  .  co m
    stage.setTitle("");

    ToggleGroup group = new ToggleGroup();
    RadioButton button1 = new RadioButton("select first");
    button1.setToggleGroup(group);
    button1.setSelected(true);
    RadioButton button2 = new RadioButton("select second");
    button2.setToggleGroup(group);

    root.getChildren().add(button1);
    root.getChildren().add(button2);

    scene.setRoot(root);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Button btn = new Button("Hello JavaFX!");

    HBox root = new HBox();
    root.getChildren().addAll(btn);//from  www. j  av a2  s .c o m

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Sizes of a Node");
    stage.show();

    btn.setWrapText(true);
    btn.setPrefWidth(80);
    stage.sizeToScene();

    System.out.println("btn.getContentBias() = " + btn.getContentBias());

    System.out.println(
            "btn.getPrefWidth() = " + btn.getPrefWidth() + ", btn.getPrefHeight() = " + btn.getPrefHeight());

    System.out.println(
            "btn.getMinWidth() = " + btn.getMinWidth() + ", btn.getMinHeight() = " + btn.getMinHeight());

    System.out.println(
            "btn.getMaxWidth() = " + btn.getMaxWidth() + ", btn.getMaxHeight() = " + btn.getMaxHeight());

    double prefWidth = btn.prefWidth(-1);
    System.out.println(
            "btn.prefWidth(-1) = " + prefWidth + ", btn.prefHeight(prefWidth) = " + btn.prefHeight(prefWidth));

    double minWidth = btn.minWidth(-1);
    System.out.println(
            "btn.minWidth(-1) = " + minWidth + ", btn.minHeight(minWidth) = " + btn.minHeight(minWidth));

    double maxWidth = btn.maxWidth(-1);
    System.out.println(
            "btn.maxWidth(-1) = " + maxWidth + ", btn.maxHeight(maxWidth) = " + btn.maxHeight(maxWidth));

    System.out.println("btn.getWidth() = " + btn.getWidth() + ", btn.getHeight() = " + btn.getHeight());
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("HBox Test");

    // HBox/*  w  w  w .j  av  a  2s. c o m*/
    HBox hb = new HBox();
    hb.setPadding(new Insets(15, 12, 15, 12));
    hb.setSpacing(10);

    // Buttons
    Button btn1 = new Button();
    btn1.setText("Button1");
    hb.getChildren().add(btn1);

    Button btn2 = new Button();
    btn2.setText("Button2");
    hb.getChildren().add(btn2);

    Button btn3 = new Button();
    btn3.setText("Button3");
    hb.getChildren().add(btn3);

    Button btn4 = new Button();
    btn4.setText("Button4");
    hb.getChildren().add(btn4);

    // Adding HBox to the scene
    Scene scene = new Scene(hb);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(400);//from  w w  w  .  j a  v  a 2 s.c o  m
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setFont(new Font("Arial", 30));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);//w  w w .j a  v a2 s . c  o m
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setFont(new Font("Arial", 30));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);/*w ww  . ja  v a 2 s. co m*/
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setTextFill(Color.web("#0076a3"));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);// w  w w  .  j a  v  a  2  s .c o  m
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setRotate(270);

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    HBox hbox = new HBox();
    Button button1 = new Button("Add               ");
    Button button2 = new Button("Remove   ");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    root.getChildren().add(hbox);/*w  w  w . j  ava 2  s .com*/
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);//from ww w.j  a  v  a 2s . c  o m
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setTranslateY(50);

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);//from w w  w . j ava 2s.  com
    stage.setHeight(180);

    HBox hbox = new HBox();

    Label label1 = new Label("Search");
    label1.setTextAlignment(TextAlignment.JUSTIFY);

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    stage.setScene(scene);
    stage.show();
}