Example usage for javafx.scene.text TextFlow getWidth

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

Introduction

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

Prototype

public final double getWidth() 

Source Link

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();// ww  w . j a v  a2 s  . c o  m
        fieldName.setMinWidth(fieldName.getWidth());
        gp.add(fieldName, 0, i);
        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();//from w  w  w . j av  a  2s . com
        fieldName.setMinWidth(fieldName.getWidth());
        gp.add(fieldName, 0, i);
        final VBox vbox = new VBox(inputElement);
        if (StringUtils.isNotBlank(description)) {
            vbox.getChildren().add(new TextFlow(new Text(description)));
        }
        gp.add(vbox, 1, i);
    }
}