Example usage for javafx.scene.text TextFlow autosize

List of usage examples for javafx.scene.text TextFlow autosize

Introduction

In this page you can find the example usage for javafx.scene.text TextFlow autosize.

Prototype

public final void autosize() 

Source Link

Document

If the node is resizable, will set its layout bounds to its current preferred width and height.

Usage

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

private void insertConfigItemsIntoGrid(final GridPane gp, final List<Triple<String, Node, String>> formItems) {
    for (int i = 0; i < formItems.size(); i++) {
        final String title = formItems.get(i).getLeft();
        final Node inputElement = formItems.get(i).getMiddle();
        final String description = formItems.get(i).getRight();

        // Put text flow object into cell. If a Text instance is used only, it will grab the whole cell size and center the text
        // (horizontally and vertically). Therefore, the table cell alignment does not work.
        final TextFlow titleText = new TextFlow(new Text(title));
        titleText.setStyle("-fx-font-weight: bold;");
        final TextFlow fieldName = new TextFlow(titleText);
        fieldName.autosize();
        fieldName.setMinWidth(fieldName.getWidth());
        gp.add(fieldName, 0, i);/*from   ww  w.  j a  va2s. c o m*/
        final Text descriptionText = new Text(description);
        final VBox vbox = new VBox(inputElement, new TextFlow(descriptionText));
        gp.add(vbox, 1, i);
    }
}

From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java

private void insertConfigItemsIntoGrid(final GridPane gp, final List<Triple<String, Node, String>> formItems) {
    for (int i = 0; i < formItems.size(); i++) {
        final String title = formItems.get(i).getLeft();
        final Node inputElement = formItems.get(i).getMiddle();
        final String description = formItems.get(i).getRight();

        // Put text flow object into cell. If a Text instance is used only, it will grab the whole cell size and center the text
        // (horizontally and vertically). Therefore, the table cell alignment does not work.
        final TextFlow titleText = new TextFlow(new Text(title));
        titleText.setStyle("-fx-font-weight: bold;");
        final TextFlow fieldName = new TextFlow(titleText);
        fieldName.autosize();
        fieldName.setMinWidth(fieldName.getWidth());
        gp.add(fieldName, 0, i);/*from   w  w w .  ja  va 2  s  .c o  m*/
        final VBox vbox = new VBox(inputElement);
        if (StringUtils.isNotBlank(description)) {
            vbox.getChildren().add(new TextFlow(new Text(description)));
        }
        gp.add(vbox, 1, i);
    }
}