Example usage for javafx.scene.control Button getMinWidth

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

Introduction

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

Prototype

public final double getMinWidth() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Button okBtn = new Button("OK");
    Button cancelBtn = new Button("Cancel");

    cancelBtn.setPrefWidth(100);//from  w ww  . j  a  v a  2  s. c o  m

    VBox root = new VBox();
    root.getChildren().addAll(okBtn, cancelBtn);

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

    System.out.println("okBtn.getPrefWidth(): " + okBtn.getPrefWidth());
    System.out.println("okBtn.getMinWidth(): " + okBtn.getMinWidth());
    System.out.println("okBtn.getMaxWidth(): " + okBtn.getMaxWidth());

    System.out.println("cancelBtn.getPrefWidth(): " + cancelBtn.getPrefWidth());
    System.out.println("cancelBtn.getMinWidth(): " + cancelBtn.getMinWidth());
    System.out.println("cancelBtn.getMaxWidth(): " + cancelBtn.getMaxWidth());
}

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 ww . ja  v  a 2  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());
}