Example usage for javafx.scene.control Button getWidth

List of usage examples for javafx.scene.control Button getWidth

Introduction

In this page you can find the example usage for javafx.scene.control Button getWidth.

Prototype

public final double getWidth() 

Source Link

Usage

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);/* w  w w  .  j a va  2s .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());
}