Example usage for javafx.scene.control TextArea setText

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

Introduction

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

Prototype

public final void setText(String value) 

Source Link

Usage

From source file:io.bitsquare.gui.components.paymentmethods.USPostalMoneyOrderForm.java

public static int addFormForBuyer(GridPane gridPane, int gridRow,
        PaymentAccountContractData paymentAccountContractData) {
    addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Account holder name:",
            ((USPostalMoneyOrderAccountContractData) paymentAccountContractData).getHolderName());
    TextArea textArea = addLabelTextArea(gridPane, ++gridRow, "Postal address:", "").second;
    textArea.setPrefHeight(60);//from  w ww.ja v  a 2 s .c  om
    textArea.setEditable(false);
    textArea.setId("text-area-disabled");
    textArea.setText(((USPostalMoneyOrderAccountContractData) paymentAccountContractData).getPostalAddress());
    return gridRow;
}

From source file:io.bitsquare.gui.components.paymentmethods.CashDepositForm.java

public static int addFormForBuyer(GridPane gridPane, int gridRow,
        PaymentAccountContractData paymentAccountContractData) {
    CashDepositAccountContractData data = (CashDepositAccountContractData) paymentAccountContractData;
    String countryCode = data.getCountryCode();
    String requirements = data.getRequirements();
    boolean showRequirements = requirements != null && !requirements.isEmpty();

    if (data.getHolderTaxId() != null)
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
                "Account holder name / email / " + BankUtil.getHolderIdLabel(countryCode),
                data.getHolderName() + " / " + data.getHolderEmail() + " / " + data.getHolderTaxId());
    else/*from   www .  ja va2 s  . c  o  m*/
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Account holder name / email:",
                data.getHolderName() + " / " + data.getHolderEmail());

    if (!showRequirements)
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Country of bank:",
                CountryUtil.getNameAndCode(countryCode));
    else
        requirements += "\nCountry of bank: " + CountryUtil.getNameAndCode(countryCode);

    // We don't want to display more than 6 rows to avoid scrolling, so if we get too many fields we combine them horizontally
    int nrRows = 0;
    if (BankUtil.isBankNameRequired(countryCode))
        nrRows++;
    if (BankUtil.isBankIdRequired(countryCode))
        nrRows++;
    if (BankUtil.isBranchIdRequired(countryCode))
        nrRows++;
    if (BankUtil.isAccountNrRequired(countryCode))
        nrRows++;
    if (BankUtil.isAccountTypeRequired(countryCode))
        nrRows++;

    String bankNameLabel = BankUtil.getBankNameLabel(countryCode);
    String bankIdLabel = BankUtil.getBankIdLabel(countryCode);
    String branchIdLabel = BankUtil.getBranchIdLabel(countryCode);
    String accountNrLabel = BankUtil.getAccountNrLabel(countryCode);
    String accountTypeLabel = BankUtil.getAccountTypeLabel(countryCode);

    boolean accountNrAccountTypeCombined = false;
    boolean bankNameBankIdCombined = false;
    boolean bankIdBranchIdCombined = false;
    boolean bankNameBranchIdCombined = false;
    boolean branchIdAccountNrCombined = false;
    if (nrRows > 2) {
        // Try combine AccountNr + AccountType
        accountNrAccountTypeCombined = BankUtil.isAccountNrRequired(countryCode)
                && BankUtil.isAccountTypeRequired(countryCode);
        if (accountNrAccountTypeCombined)
            nrRows--;

        if (nrRows > 2) {
            // Next we try BankName + BankId
            bankNameBankIdCombined = BankUtil.isBankNameRequired(countryCode)
                    && BankUtil.isBankIdRequired(countryCode);
            if (bankNameBankIdCombined)
                nrRows--;

            if (nrRows > 2) {
                // Next we try BankId + BranchId
                bankIdBranchIdCombined = !bankNameBankIdCombined && BankUtil.isBankIdRequired(countryCode)
                        && BankUtil.isBranchIdRequired(countryCode);
                if (bankIdBranchIdCombined)
                    nrRows--;

                if (nrRows > 2) {
                    // Next we try BankId + BranchId
                    bankNameBranchIdCombined = !bankNameBankIdCombined && !bankIdBranchIdCombined
                            && BankUtil.isBankNameRequired(countryCode)
                            && BankUtil.isBranchIdRequired(countryCode);
                    if (bankNameBranchIdCombined)
                        nrRows--;

                    if (nrRows > 2) {
                        branchIdAccountNrCombined = !bankNameBranchIdCombined && !bankIdBranchIdCombined
                                && !accountNrAccountTypeCombined && BankUtil.isBranchIdRequired(countryCode)
                                && BankUtil.isAccountNrRequired(countryCode);
                        if (branchIdAccountNrCombined)
                            nrRows--;

                        if (nrRows > 2)
                            log.warn("We still have too many rows....");
                    }
                }
            }
        }
    }

    if (bankNameBankIdCombined) {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
                bankNameLabel.substring(0, bankNameLabel.length() - 1) + " / "
                        + bankIdLabel.substring(0, bankIdLabel.length() - 1) + ":",
                data.getBankName() + " / " + data.getBankId());
    }
    if (bankNameBranchIdCombined) {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
                bankNameLabel.substring(0, bankNameLabel.length() - 1) + " / "
                        + branchIdLabel.substring(0, branchIdLabel.length() - 1) + ":",
                data.getBankName() + " / " + data.getBranchId());
    }

    if (!bankNameBankIdCombined && !bankNameBranchIdCombined && BankUtil.isBankNameRequired(countryCode))
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankNameLabel, data.getBankName());

    if (!bankNameBankIdCombined && !bankNameBranchIdCombined && !branchIdAccountNrCombined
            && bankIdBranchIdCombined) {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
                bankIdLabel.substring(0, bankIdLabel.length() - 1) + " / "
                        + branchIdLabel.substring(0, branchIdLabel.length() - 1) + ":",
                data.getBankId() + " / " + data.getBranchId());
    }

    if (!bankNameBankIdCombined && !bankIdBranchIdCombined && BankUtil.isBankIdRequired(countryCode))
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankIdLabel, data.getBankId());

    if (!bankNameBranchIdCombined && !bankIdBranchIdCombined && branchIdAccountNrCombined) {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
                branchIdLabel.substring(0, branchIdLabel.length() - 1) + " / "
                        + accountNrLabel.substring(0, accountNrLabel.length() - 1) + ":",
                data.getBranchId() + " / " + data.getAccountNr());
    }

    if (!bankNameBranchIdCombined && !bankIdBranchIdCombined && !branchIdAccountNrCombined
            && BankUtil.isBranchIdRequired(countryCode))
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, branchIdLabel, data.getBranchId());

    if (!branchIdAccountNrCombined && accountNrAccountTypeCombined) {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
                accountNrLabel.substring(0, accountNrLabel.length() - 1) + " / " + accountTypeLabel,
                data.getAccountNr() + " / " + data.getAccountType());
    }

    if (!branchIdAccountNrCombined && !accountNrAccountTypeCombined
            && BankUtil.isAccountNrRequired(countryCode))
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, accountNrLabel, data.getAccountNr());

    if (!accountNrAccountTypeCombined && BankUtil.isAccountTypeRequired(countryCode))
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, accountTypeLabel, data.getAccountType());

    if (showRequirements) {
        TextArea textArea = addLabelTextArea(gridPane, ++gridRow, "Extra requirements:", "").second;
        textArea.setMinHeight(45);
        textArea.setMaxHeight(45);
        textArea.setEditable(false);
        textArea.setId("text-area-disabled");
        textArea.setText(requirements);
    }

    return gridRow;
}

From source file:io.bitsquare.gui.components.paymentmethods.USPostalMoneyOrderForm.java

@Override
public void addFormForDisplayAccount() {
    gridRowFrom = gridRow;//from www.j a va 2s  .co m
    addLabelTextField(gridPane, gridRow, "Account name:", usPostalMoneyOrderAccount.getAccountName(),
            Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    addLabelTextField(gridPane, ++gridRow, "Payment method:",
            BSResources.get(usPostalMoneyOrderAccount.getPaymentMethod().getId()));
    addLabelTextField(gridPane, ++gridRow, "Account holder name:", usPostalMoneyOrderAccount.getHolderName());
    TextArea textArea = addLabelTextArea(gridPane, ++gridRow, "Postal address:", "").second;
    textArea.setText(usPostalMoneyOrderAccount.getPostalAddress());
    textArea.setPrefHeight(60);
    textArea.setEditable(false);
    addLabelTextField(gridPane, ++gridRow, "Currency:",
            usPostalMoneyOrderAccount.getSingleTradeCurrency().getNameAndCode());
    addAllowedPeriod();
}

From source file:org.kordamp.javatrove.example04.util.ApplicationEventHandler.java

@Handler
public void handleThrowable(ThrowableEvent event) {
    Platform.runLater(() -> {/*from  w w w  .ja  v a 2 s  .  co  m*/
        TitledPane pane = new TitledPane();
        pane.setCollapsible(false);
        pane.setText("Stacktrace");
        TextArea textArea = new TextArea();
        textArea.setEditable(false);
        pane.setContent(textArea);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        event.getThrowable().printStackTrace(new PrintStream(baos));
        textArea.setText(baos.toString());

        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("Error");
        alert.setHeaderText("An unexpected error occurred");
        alert.getDialogPane().setContent(pane);
        alert.showAndWait();
    });
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    final Label label = new Label("Progress:");
    final ProgressBar progressBar = new ProgressBar(0);
    final ProgressIndicator progressIndicator = new ProgressIndicator(0);

    final Button startButton = new Button("Start");
    final Button cancelButton = new Button("Cancel");
    final TextArea textArea = new TextArea();

    startButton.setOnAction((ActionEvent event) -> {
        startButton.setDisable(true);/*from   ww  w .j a v a2  s. c om*/

        progressBar.setProgress(0);
        progressIndicator.setProgress(0);

        textArea.setText("");
        cancelButton.setDisable(false);

        copyWorker = createWorker(numFiles);

        progressBar.progressProperty().unbind();
        progressBar.progressProperty().bind(copyWorker.progressProperty());
        progressIndicator.progressProperty().unbind();
        progressIndicator.progressProperty().bind(copyWorker.progressProperty());

        copyWorker.messageProperty().addListener(
                (ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
                    textArea.appendText(newValue + "\n");
                });

        new Thread(copyWorker).start();
    });

    cancelButton.setOnAction((ActionEvent event) -> {
        startButton.setDisable(false);
        cancelButton.setDisable(true);
        copyWorker.cancel(true);

        progressBar.progressProperty().unbind();
        progressBar.setProgress(0);
        progressIndicator.progressProperty().unbind();
        progressIndicator.setProgress(0);
        textArea.appendText("File transfer was cancelled.");
    });

    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 500, 250, javafx.scene.paint.Color.WHITE);

    FlowPane topPane = new FlowPane(5, 5);
    topPane.setPadding(new Insets(5));
    topPane.setAlignment(Pos.CENTER);
    topPane.getChildren().addAll(label, progressBar, progressIndicator);

    GridPane middlePane = new GridPane();
    middlePane.setPadding(new Insets(5));
    middlePane.setHgap(20);
    middlePane.setVgap(20);
    ColumnConstraints column1 = new ColumnConstraints(300, 400, Double.MAX_VALUE);
    middlePane.getColumnConstraints().addAll(column1);
    middlePane.setAlignment(Pos.CENTER);
    middlePane.add(textArea, 0, 0);

    FlowPane bottomPane = new FlowPane(5, 5);
    bottomPane.setPadding(new Insets(5));
    bottomPane.setAlignment(Pos.CENTER);
    bottomPane.getChildren().addAll(startButton, cancelButton);

    root.setTop(topPane);
    root.setCenter(middlePane);
    root.setBottom(bottomPane);

    primaryStage.setScene(scene);
    primaryStage.show();
}

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);//  w  ww. ja  v  a  2  s  . c  om
    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:de.rkl.tools.tzconv.TimezoneConverter.java

private void updateTextAreaContent(final TextArea mainArea, final ZonedDateTime dateTime) {
    final StringWriter mainAreaWriter = new StringWriter();
    fillFromTemplate(mainAreaWriter, dateTime);
    mainArea.setText(mainAreaWriter.toString());
}

From source file:com.core.meka.SOMController.java

private void borrar(TextArea... text) {
    for (TextArea t : text) {
        t.setText("");
    }
}

From source file:com.core.meka.SOMController.java

private void train() {
    if (neuronas_text.getText().isEmpty()) {
        String result = "Debe ingresar una cantidad de neuronas";
        result += "\nPor ejemplo: cantidad = 4, entonces la red contendra 4 neuronas en total";
        result_text.setText(result);//from  www  .  j ava  2 s . c  o  m
        return;
    }
    if (epocas_text.getText().isEmpty()) {
        String result = "Debe ingresar una cantidad de epocas";
        result += "\nPor ejemplo: epocas = 5, entonces la red se estabilizara luego de 5 ciclos de entrenamiento";
        result_text.setText(result);
        return;
    }
    if (entradas_text.getText().isEmpty()) {
        String result = "Debe ingresar una cantidad de entradas para el entrenamiento";
        result += "\nPor ejemplo: entradas = 3, entonces [4,2,5] es un patron valido de entrenamiento";
        result_text.setText(result);
        return;
    }
    if (patrones_train_text.getText().isEmpty()) {
        String result = "Debe ingresar algun patron de entrenamiento";
        result += "\nPor ejemplo: patrones = [1,2,4],[6,1,3], entonces la red tendra 2 patrones de entrenamiento validos";
        result_text.setText(result);
        return;
    }
    if (funcion_vecindad_combo.getSelectionModel().getSelectedIndex() < 0) {
        String result = "Debe elegir si desea utilizar una funcion de vecindad";
        result_text.setText(result);
        return;
    }
    //Valores correctos
    Integer dimension = Integer.valueOf(entradas_text.getText());
    boolean formatoPatronesEntrenamiento = SOMManager.validarDimensionArreglo(dimension,
            patrones_train_text.getText());
    if (!formatoPatronesEntrenamiento) {
        String result = "Los patrones ingresados no tienen una dimension correcta";
        result += "\nPor ejemplo: 1.3,2.6 ; 5.6,22,55,66 (2 patrones) es incorrecto Dimension(p1) = 2 y Dimension(p2) = 4";
        result_text.setText(result);
        return;
    }

    if (!pesos_check.isSelected()) {
        boolean formatoPesos = SOMManager.validarDimensionArreglo(dimension, pesos_text.getText());
        if (!formatoPesos) {
            String result = "Los pesos ingresados no tienen una dimension correcta";
            result += "\nPor ejemplo: 1.8,3.6 ; 7.6,12,5,1 (2 patrones) es incorrecto Dimension(p1) = 2 y Dimension(p2) = 4";
            result_text.setText(result);
            return;
        }
    }

    //Correcto, realizar operaciones solicitadas
    Integer epocas = Integer.valueOf(epocas_text.getText());
    Boolean pesosAleatorios = pesos_check.isSelected();
    Boolean utilizarFuncionVecindad = funcion_vecindad_combo.getSelectionModel().getSelectedIndex() == 0;
    Integer clusters = Integer.valueOf(neuronas_text.getText());
    try {
        double[][] patrones = crearArreglo(
                patrones_train_text.getText().replaceAll("\\s+", "").replaceAll("\\n+", "").split(";"),
                result_text);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                crearCluster(dimension, epocas, pesosAleatorios, utilizarFuncionVecindad, clusters, patrones,
                        (pesosAleatorios ? null
                                : crearArreglo(pesos_text.getText().replaceAll("\\s+", "")
                                        .replaceAll("\\n+", "").split(";"), result_text)));
                test_tab.setDisable(false);
                mostrarNeuronasTest(som, neuronas_test_text);
            }

            private void mostrarNeuronasTest(SOMCluster som, TextArea neuronas_test_text) {
                double[][] W = som.getW();
                String neuronas = Matrix.getMatrix(W);
                neuronas_test_text.setText(neuronas);
            }
        });

    } catch (NumberFormatException e) {
        //                    result_text.setText("Imposible formatear ese numero, verifiquelo\n" + e.getMessage().replaceAll("\\)", ")\n") + 
        //                            "\n\n" + result_text.getText());
    }
}

From source file:sudoku.controller.ViewController.java

public void attachTextEventHandlers(ArrayList<TextArea> textAreas) {
    for (TextArea textArea : textAreas) {
        textArea.textProperty().addListener((final ObservableValue<? extends String> observable,
                final String oldValue, final String newValue) -> {
            String parentID = textArea.getParent().getId();
            //get the row and column of the cell
            int row = parentID.charAt(0) - 48;
            int column = parentID.charAt(1) - 48;

            System.out.println("Parent: " + textArea.getParent().getId());
            //if it's an empty cell
            if (newValue.equals(""))
                GameController.userBoard[row][column] = 0;

            // if the length is greater than 1, it's an invalid input
            if (newValue.length() > 1)
                textArea.setText(oldValue);
            //make sure that the user is actually providing a +ve number greater than 0 as an input
            if (newValue.length() > 0) {
                int value = newValue.charAt(0) - 48;
                if (!Character.isDigit(newValue.charAt(0)) || newValue.charAt(0) == 48) {
                    textArea.setText("");
                    GameController.userBoard[row][column] = 0;
                } else {
                    //for an illegal move, set the cell's text to a red color
                    if (!solver.isLegal(GameController.userBoard, row, column, value)) {
                        textArea.setStyle("-fx-text-fill: red;");
                    } else {
                        textArea.setStyle("-fx-text-fill: black;");
                    }/*from w ww  .j av a 2 s .c o m*/
                    GameController.userBoard[row][column] = value;
                }
            }
        });
    }
}