Example usage for javafx.scene.control TextArea getText

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

Introduction

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

Prototype

public final String getText() 

Source Link

Usage

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

public void runLogFileReader(final RadioButton inputTypeFile, final TextField pathInput,
        final TextArea logInputText) {
    this.parsedLogEntryItems.clear();

    try {//from w  ww. j  av a2  s.c  om
        GenericLogReader reader;
        if (inputTypeFile.isSelected()) {
            reader = new GenericLogReader(new File(pathInput.getText()));
        } else {
            reader = new GenericLogReader(new BufferedReader(new StringReader(logInputText.getText())));
        }
        reader.overwriteCurrentSettingsWithSettingsInConfigurationFile(
                this.logReader.getSettingsForConfigurationFile());
        this.logReader = reader;
        ILogEntry nextLogEntry;
        while ((nextLogEntry = reader.getNextEntry()) != null) {
            this.parsedLogEntryItems.add(new LogEntryTableRow(nextLogEntry));
        }
    } catch (final RuntimeException re) {
        ExceptionDialog.showFatalException("Error reading log entries",
                "An error occurred while reading the log entries.", re);
    }
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

private void initGenerateXPathFromStackTrace() {

    ContextMenu menu = new ContextMenu();

    MenuItem item = new MenuItem("Generate from stack trace...");
    item.setOnAction(e -> {//from   w w  w.  j av a 2 s.  c om
        try {
            Stage popup = new Stage();
            FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml"));
            Parent root = loader.load();
            Button button = (Button) loader.getNamespace().get("generateButton");
            TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea");

            ValidationSupport validation = new ValidationSupport();

            validation.registerValidator(area,
                    Validator.createEmptyValidator("The stack trace may not be empty"));
            button.disableProperty().bind(validation.invalidProperty());

            button.setOnAction(f -> {
                DesignerUtil.stackTraceToXPath(area.getText()).ifPresent(xpathExpressionArea::replaceText);
                popup.close();
            });

            popup.setScene(new Scene(root));
            popup.initStyle(StageStyle.UTILITY);
            popup.initModality(Modality.WINDOW_MODAL);
            popup.initOwner(designerRoot.getMainStage());
            popup.show();
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
    });

    menu.getItems().add(item);

    xpathExpressionArea.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
        if (t.getButton() == MouseButton.SECONDARY) {
            menu.show(xpathExpressionArea, t.getScreenX(), t.getScreenY());
        }
    });
}

From source file:FeeBooster.java

@Override
public void start(Stage primaryStage) throws Exception {

    // Setup the stage
    stage = primaryStage;// w ww  . j  av  a  2  s  . c  o m
    primaryStage.setTitle("Bitcoin Transaction Fee Booster");

    // Setup intro gridpane
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    // Intro Text
    Text scenetitle = new Text(
            "Welcome to the fee booster. \n\nWhat type of transaction would you like to boost the fee of?");
    grid.add(scenetitle, 0, 0, 2, 3);

    // radio button selections
    VBox boostRadioVbox = new VBox();
    ToggleGroup boostTypeGroup = new ToggleGroup();
    RadioButton rbfRadio = new RadioButton("A transaction you sent");
    rbfRadio.setToggleGroup(boostTypeGroup);
    boostRadioVbox.getChildren().add(rbfRadio);
    RadioButton cpfpRadio = new RadioButton("A transaction you received");
    cpfpRadio.setToggleGroup(boostTypeGroup);
    rbfRadio.setSelected(true);
    boostRadioVbox.getChildren().add(cpfpRadio);
    grid.add(boostRadioVbox, 0, 3);

    // Instructions Text
    Text instruct = new Text("Please enter the raw hex or transaction id of your transaction below:");
    grid.add(instruct, 0, 4);

    // Textbox for hex of transaction
    TextArea txHexTxt = new TextArea();
    txHexTxt.setWrapText(true);
    grid.add(txHexTxt, 0, 5, 5, 1);

    // Next Button
    Button nextBtn = new Button("Next");
    nextBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {

            // Create Transaction
            Transaction tx = new Transaction();

            // Check if txid
            boolean isTxid = txHexTxt.getText().length() == 64 && txHexTxt.getText().matches("[0-9A-Fa-f]+");
            if (isTxid)
                tx.setHash(txHexTxt.getText());

            // Determine which page to go to
            if (Transaction.deserializeStr(txHexTxt.getText(), tx) || isTxid) {

                // Get the fee
                JSONObject apiResult = Utils
                        .getFromAnAPI("https://api.blockcypher.com/v1/btc/main/txs/" + tx.getHash(), "GET");

                // Get the fee
                tx.setFee(apiResult.getInt("fees"));
                tx.setTotalAmtPre(tx.getFee() + tx.getOutAmt());

                // Get info if txid
                if (isTxid) {

                }

                Scene scene = null;
                if (rbfRadio.isSelected())
                    if (sceneCursor == scenes.size() - 1 || !rbf) {
                        scene = new Scene(rbfGrid(tx), 900, 500);
                        if (!rbf) {
                            scenes.clear();
                            scenes.add(stage.getScene());
                        }
                        rbf = true;
                    }
                if (cpfpRadio.isSelected())
                    if (sceneCursor == scenes.size() - 1 || rbf) {
                        scene = new Scene(cpfpGrid(tx), 900, 500);
                        if (rbf) {
                            scenes.clear();
                            scenes.add(stage.getScene());
                        }
                        rbf = false;
                    }

                if (sceneCursor != scenes.size() - 1)
                    scene = scenes.get(sceneCursor + 1);
                else
                    scenes.add(scene);
                sceneCursor++;
                stage.setScene(scene);
            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR, "Please enter a valid transaction");
                alert.showAndWait();
            }
        }
    });
    HBox btnHbox = new HBox(10);
    btnHbox.getChildren().add(nextBtn);

    // Cancel Button
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setOnAction(cancelEvent);
    btnHbox.getChildren().add(cancelBtn);
    grid.add(btnHbox, 2, 7);

    // Display everything
    Scene scene = new Scene(grid, 900, 500);
    scenes.add(scene);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:FeeBooster.java

private GridPane broadcastTxGrid(Transaction tx) {
    // Setup Grid
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);//from  w w  w  . j a  va  2s  .  c  o m
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    // Instructions Text
    Text instructions = new Text("Enter your signed transaction into the space below.");
    grid.add(instructions, 0, 0);

    // Put signed transaction in text area
    TextArea signedTxTxt = new TextArea();
    signedTxTxt.setWrapText(true);
    grid.add(signedTxTxt, 0, 1);

    // Display some info about Transaction after sent
    Text txInfo = new Text();
    grid.add(txInfo, 0, 4);

    // Add Next Button
    Button nextBtn = new Button("Send Transaction");
    nextBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            Transaction signedTx = new Transaction();
            Transaction.deserializeStr(signedTxTxt.getText(), signedTx);
            txInfo.setText("Transaction being broadcast. TXID: " + signedTx.getHash()
                    + "\nPlease wait a few minutes for best results, but you may now exit.");
            Broadcaster.broadcastTransaction(Transaction.serialize(signedTx, false));
        }
    });
    HBox btnHbox = new HBox(10);

    // Back Button
    Button backBtn = new Button("Back");
    backBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            sceneCursor--;
            stage.setScene(scenes.get(sceneCursor));
        }
    });
    btnHbox.getChildren().add(backBtn);
    btnHbox.getChildren().add(nextBtn);

    // Cancel Button
    Button cancelBtn = new Button("Exit");
    cancelBtn.setOnAction(cancelEvent);
    btnHbox.getChildren().add(cancelBtn);
    grid.add(btnHbox, 0, 2);

    return grid;
}

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

private double[][] crearArreglo(String[] patrones, TextArea resultArea) throws NumberFormatException {
    int totalPatrones = patrones.length;
    int dimension = patrones[0].split(",").length;
    double[][] result = new double[totalPatrones][dimension];

    for (int i = 0; i < totalPatrones; i++) {
        String[] patron = patrones[i].split(",");
        double[] patronDouble = new double[dimension];
        for (int j = 0; j < patron.length; j++) {
            try {
                patronDouble[j] = Double.valueOf(patron[j]);
            } catch (NumberFormatException e) {
                resultArea.setText("Imposible formatear ese numero, verifiquelo\n"
                        + e.getMessage().replaceAll("\\)", ")\n")
                                .replaceAll("For input string", "Cadena de entrada")
                                .replaceAll("multiple points", "Puntos multiples")
                        + ": " + patron[j] + "\n\n" + resultArea.getText());
                throw new NumberFormatException("Imposible formatear ese numero, veriquelo");
            }//from   ww  w  .j a  v  a 2  s .co m
        }
        result[i] = patronDouble;
    }

    return result;
}

From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java

private Optional<String> askUserForTextArea(String label, String initialText) {
    TextArea textarea = new TextArea();
    if (initialText != null)
        textarea.setText(initialText);/*from   w  w  w.  ja v a 2 s. co m*/

    Dialog<ButtonType> dialog = new Dialog<>();
    dialog.getDialogPane().headerTextProperty().set(label);
    dialog.getDialogPane().contentProperty().set(textarea);
    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    Optional<ButtonType> result = dialog.showAndWait();

    if (result.isPresent() && result.get().equals(ButtonType.OK))
        return Optional.of(textarea.getText());
    else
        return Optional.empty();
}

From source file:com.virus.removal.javafxapplication.FXMLDocumentController.java

/**
 * @param textAreaForHistory/*from www. j  av  a 2 s  .co  m*/
 */
public void writeVirusScanHistoryIntoFile(final TextArea textAreaForHistory) {

    try {

        final String userWorkingDrive = System.getProperty("user.dir").split(":")[0];

        System.out.println(userWorkingDrive);

        final File file = new File(userWorkingDrive + ":" + File.separator + "VirusScanHistory" + File.separator
                + virusScanHistoryFile);

        file.getParentFile().mkdirs();
        if (!file.exists()) {
            file.createNewFile();
        }

        final FileWriter fw = new FileWriter(file.getAbsoluteFile());
        final BufferedWriter bw = new BufferedWriter(fw);

        if (StringUtils.isNotBlank(textAreaForHistory.getText())
                && !StringUtils.contains(textAreaForHistory.getText(), HISTORY_UNAVAILABLE)
                && !StringUtils.contains(textAreaForHistory.getText(), HISTORY_UNAVAILABLE_IN_SPANISH)
                && !StringUtils.contains(textAreaForHistory.getText(), HISTORY_UNAVAILABLE_IN_FRENCH)
                && !StringUtils.contains(textAreaForHistory.getText(), HISTORY_UNAVAILABLE_IN_PORTUGUESE)) {
            bw.write(textAreaForHistory.getText());
        } else {
            bw.write("");
        }

        bw.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.virus.removal.javafxapplication.FXMLDocumentController.java

/**
 * @return/*from   w w w .  j  a  v  a2 s  . c o  m*/
 */
public TextArea readVirusScanHistoryFromFile() {

    BufferedReader br = null;
    final TextArea textArea = new TextArea();

    try {

        String currentLine;
        final String userWorkingDrive = System.getProperty("user.dir").split(":")[0];

        System.out.println(userWorkingDrive);

        final File file = new File(userWorkingDrive + ":" + File.separator + "VirusScanHistory" + File.separator
                + virusScanHistoryFile);

        System.out.println(file.getParentFile().getAbsolutePath());

        if (file.exists()) {
            br = new BufferedReader(new FileReader(file.getAbsolutePath()));
            while ((currentLine = br.readLine()) != null) {
                if (!currentLine.isEmpty()) {
                    if (StringUtils.contains(currentLine, "PC Name:")) {
                        textArea.appendText(currentLine + "\n\n\n\n");
                    } else {
                        textArea.appendText(currentLine + "\n\n");
                    }
                }
                System.out.println(currentLine);
            }
            System.out.println(textArea.getText());
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (br != null) {
                br.close();
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    return textArea;
}

From source file:editeurpanovisu.EditeurPanovisu.java

private void sauveFichierProjet() throws IOException {
    repertoireProjet = fichProjet.getParent();
    repertSauveChoisi = true;//from   w w w .  j a  v  a 2 s .  c o m
    File fichierProjet = new File(fichProjet.getAbsolutePath());
    if (!fichierProjet.exists()) {
        fichierProjet.createNewFile();
    }
    dejaSauve = true;
    stPrincipal.setTitle("Panovisu v" + numVersion + " : " + fichProjet.getAbsolutePath());

    String contenuFichier = "";
    TextArea tfVisite = (TextArea) paneChoixPanoramique.lookup("#titreVisite");
    if (!tfVisite.getText().equals("")) {
        contenuFichier += "[titreVisite=>" + tfVisite.getText() + "]\n";
    }
    if (!panoEntree.equals("")) {
        contenuFichier += "[PanoEntree=>" + panoEntree + "]\n";
    }
    for (int i = 0; i < nombrePanoramiques; i++) {
        contenuFichier += "[Panoramique=>" + "fichier:" + panoramiquesProjet[i].getNomFichier() + ";nb:"
                + panoramiquesProjet[i].getNombreHotspots() + ";nbImg:"
                + panoramiquesProjet[i].getNombreHotspotImage() + ";titre:"
                + panoramiquesProjet[i].getTitrePanoramique() + "" + ";type:"
                + panoramiquesProjet[i].getTypePanoramique() + ";afficheInfo:"
                + panoramiquesProjet[i].isAfficheInfo() + ";afficheTitre:"
                + panoramiquesProjet[i].isAfficheTitre() + ";regardX:" + panoramiquesProjet[i].getLookAtX()
                + ";regardY:" + panoramiquesProjet[i].getLookAtY() + ";zeroNord:"
                + panoramiquesProjet[i].getZeroNord() + ";affichePlan:" + panoramiquesProjet[i].isAffichePlan()
                + ";numeroPlan:" + panoramiquesProjet[i].getNumeroPlan() + "]\n";
        for (int j = 0; j < panoramiquesProjet[i].getNombreHotspots(); j++) {
            HotSpot HS = panoramiquesProjet[i].getHotspot(j);
            contenuFichier += "   [hotspot==>" + "longitude:" + HS.getLongitude() + ";latitude:"
                    + HS.getLatitude() + ";image:" + HS.getFichierImage() + ";xml:" + HS.getFichierXML()
                    + ";info:" + HS.getInfo() + ";anime:" + HS.isAnime() + "]\n";
        }
        for (int j = 0; j < panoramiquesProjet[i].getNombreHotspotImage(); j++) {
            HotspotImage HS = panoramiquesProjet[i].getHotspotImage(j);
            contenuFichier += "   [hotspotImage==>" + "longitude:" + HS.getLongitude() + ";latitude:"
                    + HS.getLatitude() + ";image:" + HS.getFichierImage() + ";img:" + HS.getLienImg()
                    + ";urlImg:" + HS.getUrlImage() + ";info:" + HS.getInfo() + ";anime:" + HS.isAnime()
                    + "]\n";
        }
    }
    contenuFichier += "[Interface=>\n" + gestionnaireInterface.getTemplate() + "]\n";
    contenuFichier += gestionnairePlan.getTemplate();
    fichProjet.setWritable(true);
    FileWriter fw = new FileWriter(fichProjet);
    try (BufferedWriter bw = new BufferedWriter(fw)) {
        bw.write(contenuFichier);
    }
    Dialogs.create().title("Sauvegarde de fichier").message("Votre fichier  bien t sauvegard")
            .showInformation();

}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 *//* w ww  .j  a  va2  s.  c o m*/
private void valideHS() {

    for (int i = 0; i < panoramiquesProjet[panoActuel].getNombreHotspots(); i++) {
        ComboBox cbx = (ComboBox) outils.lookup("#cbpano" + i);
        TextArea txtTexteHS = (TextArea) outils.lookup("#txtHS" + i);
        if (txtTexteHS != null) {
            panoramiquesProjet[panoActuel].getHotspot(i).setInfo(txtTexteHS.getText());
        }
        if (cbx != null) {
            panoramiquesProjet[panoActuel].getHotspot(i).setFichierXML(cbx.getValue() + ".xml");
        }
        CheckBox cbAnime = (CheckBox) outils.lookup("#anime" + i);
        if (cbAnime != null) {
            if (cbAnime.isSelected()) {
                panoramiquesProjet[panoActuel].getHotspot(i).setAnime(true);
            } else {
                panoramiquesProjet[panoActuel].getHotspot(i).setAnime(false);
            }
        }
    }
    for (int i = 0; i < panoramiquesProjet[panoActuel].getNombreHotspotImage(); i++) {
        TextArea txtTexteHS = (TextArea) outils.lookup("#txtHSImage" + i);
        if (txtTexteHS != null) {
            panoramiquesProjet[panoActuel].getHotspotImage(i).setInfo(txtTexteHS.getText());
        }
        CheckBox cbAnime = (CheckBox) outils.lookup("#animeImage" + i);
        if (cbAnime != null) {
            if (cbAnime.isSelected()) {
                panoramiquesProjet[panoActuel].getHotspotImage(i).setAnime(true);
            } else {
                panoramiquesProjet[panoActuel].getHotspotImage(i).setAnime(false);
            }
        }
    }

}