Example usage for javafx.scene.control TextArea setMaxHeight

List of usage examples for javafx.scene.control TextArea setMaxHeight

Introduction

In this page you can find the example usage for javafx.scene.control TextArea setMaxHeight.

Prototype

public final void setMaxHeight(double value) 

Source Link

Usage

From source file:UI.MainStageController.java

/**
 * creates the file not found alert box//from w  w w .  j a v  a 2s  .  c o m
 */
private void fileNotFoundAlertBox() {
    fileNotFoundAlert = new Alert(Alert.AlertType.ERROR);
    fileNotFoundAlert.setTitle("File not found");
    fileNotFoundAlert.setHeaderText("File not found");
    fileNotFoundAlert.setContentText("Could not find the file you were looking for");

    //style the alert
    DialogPane dialogPane = fileNotFoundAlert.getDialogPane();
    dialogPane.getStylesheets().add("/UI/alertStyle.css");

    Exception fileNotFoundException = new FileNotFoundException("Could not find your selected file");

    //create expandable exception
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    fileNotFoundException.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was: ");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    // Set expandable Exception into the dialog pane.
    fileNotFoundAlert.getDialogPane().setExpandableContent(expContent);
    fileNotFoundAlert.showAndWait();
}