Example usage for javafx.scene.control TextArea setPrefRowCount

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

Introduction

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

Prototype

public final void setPrefRowCount(int value) 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Borders");
    Group root = new Group();
    Scene scene = new Scene(root, 600, 330, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);/*  www  .  j  av a 2  s.  c o  m*/
    gridpane.setVgap(10);

    final TextArea cssEditorFld = new TextArea();
    cssEditorFld.setPrefRowCount(10);
    cssEditorFld.setPrefColumnCount(100);
    cssEditorFld.setWrapText(true);
    cssEditorFld.setPrefWidth(150);
    GridPane.setHalignment(cssEditorFld, HPos.CENTER);
    gridpane.add(cssEditorFld, 0, 1);

    String cssDefault = "line1;\nline2;\n";

    cssEditorFld.setText(cssDefault);

    root.getChildren().add(gridpane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox root = new VBox(5);

    Label textLbl = new Label("Text:");
    TextArea text = new TextArea();
    text.setPrefRowCount(10);
    text.setPrefColumnCount(20);//  ww  w.  j av  a 2 s  .c om
    text.setWrapText(true);

    // Button to print the TextArea node
    Button printTextBtn = new Button("Print Text");
    printTextBtn.setOnAction(e -> print(text));

    // Button to print the entire scene
    Button printSceneBtn = new Button("Print Scene");
    printSceneBtn.setOnAction(e -> print(root));

    HBox buttonBox = new HBox(5, printTextBtn, printSceneBtn);

    root.getChildren().addAll(textLbl, text, buttonBox);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Printing Nodes");
    stage.show();
}

From source file:Main.java

private VBox getCenter() {
    Label nameLbl = new Label("Name:");
    TextField nameFld = new TextField();
    HBox.setHgrow(nameFld, Priority.ALWAYS);
    HBox nameFields = new HBox(nameLbl, nameFld);

    Label descLbl = new Label("Description:");
    TextArea descText = new TextArea();
    descText.setPrefColumnCount(20);//w  w w  . ja  v  a2  s .c om
    descText.setPrefRowCount(5);
    VBox.setVgrow(descText, Priority.ALWAYS);

    VBox center = new VBox(nameFields, descLbl, descText);
    return center;
}

From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java

protected void createTextAreaInput(final int numLines, final ConfigFrame cf, final String propertyName,
        final String initialValue, final Consumer<String> applyValue) {
    final TextArea inputField = new TextArea(initialValue);
    inputField.setPrefRowCount(numLines);
    inputField.setWrapText(true);//from w ww.  jav a 2  s  . c o  m
    inputField.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        applyValue.accept(newValue);
        this.getGraph().handleChange();
    });
    cf.addOption(propertyName, inputField);
}

From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java

@Override
public Node getConfigFrame() {
    // TODO: Remove code redundancies; element creating methods have been created in class AutomatonEdge and should be centralized!
    final ConfigFrame cf = new ConfigFrame("State properties");

    final int nameInputLines = 1;
    final TextArea nameInput = new TextArea(this.name);
    nameInput.setPrefRowCount(nameInputLines);
    nameInput.setWrapText(true);//from w  w w  . j  a  v  a2 s .c  o  m
    nameInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        this.setName(newValue);
        this.getGraph().handleChange();
    });
    cf.addOption("Name", nameInput);

    final int descriptionInputLines = 3;
    this.createTextAreaInput(descriptionInputLines, cf, "Description", this.getDescription(),
            newValue -> this.setDescription(newValue));

    final VBox typeAttributes = new VBox();
    final ToggleGroup flagToggleGroup = new ToggleGroup();
    typeAttributes.getChildren()
            .add(this.createRadioButtonForType(null, "None (intermediate node)", flagToggleGroup));
    typeAttributes.getChildren().add(this.createRadioButtonForType(Type.INITIAL, "Initial", flagToggleGroup));
    final RadioButton successOption = this.createRadioButtonForType(Type.SUCCESS, "Success", flagToggleGroup);
    typeAttributes.getChildren().add(successOption);
    typeAttributes.getChildren().add(this.createRadioButtonForType(Type.FAILURE, "Failure", flagToggleGroup));
    cf.addOption("Type", typeAttributes);

    final CheckBox waitCheckBox = new CheckBox("Active");
    waitCheckBox.setSelected(this.wait);
    waitCheckBox.setOnAction(event -> {
        this.setWait(waitCheckBox.isSelected());
        this.getGraph().handleChange();
    });
    cf.addOption("Wait", waitCheckBox);

    final int expressionInputLines = 1;
    final TextArea successCheckExpInput = new TextArea(this.successCheckExp);
    successCheckExpInput.setStyle("-fx-font-family: monospace");
    successCheckExpInput.setPrefRowCount(expressionInputLines);
    successCheckExpInput.setWrapText(false);
    successCheckExpInput.textProperty()
            .addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
                this.setSuccessCheckExp(newValue);
                this.getGraph().handleChange();
            });
    successCheckExpInput.disableProperty().bind(successOption.selectedProperty().not());
    cf.addOption("Script expression to verify if node is successful", successCheckExpInput);

    this.createEnterAndLeaveScriptConfig(cf);

    return cf;
}

From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java

public void createEnterAndLeaveScriptConfig(final ConfigFrame cf) {
    final int scriptInputLines = 3;
    final TextArea onEnterScriptInput = new TextArea(this.onEnter);
    onEnterScriptInput.setStyle("-fx-font-family: monospace");
    onEnterScriptInput.setPrefRowCount(scriptInputLines);
    onEnterScriptInput.setWrapText(false);
    onEnterScriptInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        this.setOnEnter(newValue);
        this.getGraph().handleChange();
    });/*from   w w  w.  j  a v a  2  s .  c om*/
    cf.addOption("When entering state, run script", onEnterScriptInput);

    final TextArea onLeaveScriptInput = new TextArea(this.onLeave);
    onLeaveScriptInput.setStyle("-fx-font-family: monospace");
    onLeaveScriptInput.setPrefRowCount(scriptInputLines);
    onLeaveScriptInput.setWrapText(false);
    onLeaveScriptInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        this.setOnLeave(newValue);
        this.getGraph().handleChange();
    });
    cf.addOption("When leaving state, run script", onLeaveScriptInput);
}

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

public VBox createRunForm() {
    // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables.
    final VBox lines = new VBox();
    lines.setSpacing(10d);/* w  ww  . j ava 2s . com*/
    final HBox inputTypeLine = new HBox();
    inputTypeLine.setSpacing(30d);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter text");
    inputTypeText.setToggleGroup(group);
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    inputTypeText.setSelected(true);
    final TextField pathInput = new TextField();
    HBox.setHgrow(pathInput, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(pathInput,
            LOG_FILE_ICON_NAME, "Select log file", null, null);
    final Text pathInputLabel = new Text("Log file path: ");
    final HBox fileInputConfig = new HBox();
    fileInputConfig.setAlignment(Pos.CENTER_LEFT);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    fileInputConfig.getChildren().addAll(pathInputLabel, pathInput, selectLogFileButton);
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    logInputText.setPrefRowCount(10);
    logInputText.setStyle("-fx-font-family: monospace");
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    final Button startBtn = new Button("Read Log");
    startBtn.setPadding(new Insets(8d));
    // CHECKSTYLE:ON
    startBtn.setGraphic(Icons.getIconGraphics("control_play_blue"));
    HBox.setHgrow(startBtn, Priority.ALWAYS);
    startBtn.setMaxWidth(Double.MAX_VALUE);
    startBtn.setOnAction(event -> this.runLogFileReader(inputTypeFile, pathInput, logInputText));
    final HBox startLine = new HBox();
    startLine.getChildren().add(startBtn);
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig, startLine, new Text("Results:"),
            this.parsedLogEntries);
    return lines;
}

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

public void createLogFileSourceInputItems(final List<Triple<String, Node, String>> formItems) {
    final TextField logFilePath = new TextField();
    this.logFilePathProperty.bind(logFilePath.textProperty());
    HBox.setHgrow(logFilePath, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(logFilePath,
            LogReaderEditor.LOG_FILE_ICON_NAME, "Select log file", null, null);
    final HBox fileInputConfig = new HBox(logFilePath, selectLogFileButton);
    final VBox lines = new VBox();
    final double spacingOfLines = 5d;
    lines.setSpacing(spacingOfLines);//from   w ww. java 2  s  .  com
    final HBox inputTypeLine = new HBox();
    final double hSpacingOfInputTypeChoices = 30d;
    inputTypeLine.setSpacing(hSpacingOfInputTypeChoices);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter log");
    inputTypeText.setToggleGroup(group);
    this.loadLogFromEnteredTextProperty.bind(inputTypeText.selectedProperty());
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    this.loadLogFromFileProperty.bind(inputTypeFile.selectedProperty());
    inputTypeFile.setSelected(true);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    final int numLinesForEnteringLogInputManually = 10;
    logInputText.setPrefRowCount(numLinesForEnteringLogInputManually);
    logInputText.setStyle("-fx-font-family: monospace");
    this.enteredLogTextProperty.bind(logInputText.textProperty());
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig);
    formItems.add(Triple.of("Trace Log", lines, null));
}

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

private List<Triple<String, Node, String>> createConfigurationForm() {
    final List<Triple<String, Node, String>> formItems = new ArrayList<>();

    // Automaton file
    final TextField automatonFilePath = new TextField();
    this.automatonFilePathProperty.bind(automatonFilePath.textProperty());
    HBox.setHgrow(automatonFilePath, Priority.ALWAYS);
    final Button selectAutomatonFilePathButton = SelectFileButton.createButtonWithFileSelection(
            automatonFilePath, Editor.Type.AUTOMATON.getIconName(), "Select " + Editor.Type.AUTOMATON.getName(),
            Editor.Type.AUTOMATON.getFileMask(), Editor.Type.AUTOMATON.getFileDescription());
    final HBox automatonFilePathConfig = new HBox(automatonFilePath, selectAutomatonFilePathButton);
    formItems.add(Triple.of("Automaton", automatonFilePathConfig, null));

    // Automaton parameters
    final TextArea parametersInputText = new TextArea();
    parametersInputText.setStyle("-fx-font-family: monospace");
    HBox.setHgrow(parametersInputText, Priority.ALWAYS);
    final int parametersInputLinesSize = 4;
    parametersInputText.setPrefRowCount(parametersInputLinesSize);
    this.parametersProperty.bind(parametersInputText.textProperty());
    formItems.add(Triple.of("Parameters", parametersInputText,
            "Set parameters for the execution. Each line can contain a parameter as follows: ${PARAMETER}=value, e.g. ${TIMEOUT}=10."));

    // Log file/*from   w w w. j a  v  a  2 s.c  om*/
    this.createLogFileSourceInputItems(formItems);

    // Log reader configuration file
    final TextField logReaderConfigurationFilePath = new TextField();
    this.logReaderConfigurationFilePathProperty.bind(logReaderConfigurationFilePath.textProperty());
    HBox.setHgrow(logReaderConfigurationFilePath, Priority.ALWAYS);
    final Button selectLogReaderConfigurationFilePathButton = SelectFileButton.createButtonWithFileSelection(
            logReaderConfigurationFilePath, Editor.Type.LOG_READER_CONFIG.getIconName(),
            "Select " + Editor.Type.LOG_READER_CONFIG.getName(), Editor.Type.LOG_READER_CONFIG.getFileMask(),
            Editor.Type.LOG_READER_CONFIG.getFileDescription());
    final HBox logReaderConfigurationFilePathConfig = new HBox(logReaderConfigurationFilePath,
            selectLogReaderConfigurationFilePathButton);
    formItems.add(Triple.of("Log Reader Configuration", logReaderConfigurationFilePathConfig, null));

    // Debug output
    final CheckBox cb = new CheckBox();
    this.showDebugOutputProperty.bind(cb.selectedProperty());
    formItems.add(Triple.of("Show Debug Output", cb,
            "Show verbose debug output. Might generate lots of text and slows down the"
                    + " evaluation, but is very helpful for debugging automatons while developing them."));

    return formItems;
}

From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java

protected void createTextAreaInput(final int numLines, final ConfigFrame cf, final String propertyName,
        final String initialValue, final Consumer<String> applyValue, final Monospace monospace) {
    final TextArea inputField = new TextArea(initialValue);
    this.setMonospaceIfDesired(monospace, inputField);
    inputField.setPrefRowCount(numLines);
    inputField.setWrapText(true);/*from   w w w.  j  a  v  a2  s  . co  m*/
    inputField.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        applyValue.accept(newValue);
        this.getGraph().handleChange();
    });
    cf.addOption(propertyName, inputField);
}