Example usage for javafx.scene.control TextArea setEditable

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

Introduction

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

Prototype

public final void setEditable(boolean value) 

Source Link

Usage

From source file:de.pixida.logtest.designer.commons.ExceptionDialog.java

public static void showFatalException(final String title, final String message, final Throwable exception) {
    final Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.initStyle(StageStyle.UTILITY);
    alert.setTitle("Error");
    alert.setHeaderText(title);/*w  w  w. j  av  a2s  .  c  o  m*/
    alert.setContentText(message);

    final Label label = new Label("Details:");

    final TextArea textArea = new TextArea(ExceptionUtils.getStackTrace(exception));
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    final GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();
}

From source file:jlotoprint.MainViewController.java

public static void showExceptionAlert(String message, String details) {
    Alert alert = new Alert(Alert.AlertType.ERROR, message, ButtonType.OK);
    alert.initModality(Modality.APPLICATION_MODAL);
    alert.initOwner(JLotoPrint.stage.getScene().getWindow());
    TextArea textArea = new TextArea(details);
    textArea.setEditable(false);
    textArea.setWrapText(true);/*from   www . j  av a  2 s  .  co  m*/

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 0, 10));
    grid.add(textArea, 0, 0);

    //set content
    alert.getDialogPane().setExpandableContent(grid);
    alert.showAndWait();
}

From source file:net.thirdy.blackmarket.controls.Dialogs.java

public static void showExceptionDialog(Throwable throwable) {
    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle("Sorry something wrong happened");
    String header = throwable.getMessage();
    header = isBlank(header) ? throwable.getClass().getSimpleName() : header;
    alert.setHeaderText(header);//from  w  w  w .jav  a 2 s. c  om
    //      alert.setGraphic(new ImageView(ImageCache.getInstance().get("/images/gallio/gallio-"
    //            + comics[RandomUtils.nextInt(0, 3)] +
    //            ".png")));
    alert.setGraphic(new ImageView(ImageCache.getInstance().get("/images/gallio/gallio-sad.png")));

    // Create expandable Exception.
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    throwable.printStackTrace(pw);
    String exceptionText = sw.toString();

    StringBuilder sb = new StringBuilder();
    //      sb.append("Error Message: ");
    //      sb.append(System.lineSeparator());
    //      sb.append(throwable.getMessage());
    sb.append("The exception stacktrace was:");
    sb.append(System.lineSeparator());
    sb.append(exceptionText);

    TextArea textArea = new TextArea(sb.toString());
    textArea.setEditable(false);
    textArea.setWrapText(false);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(150);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(textArea);
    alert.getDialogPane().setExpanded(true);

    alert.showAndWait();
}

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   ww w.  j a  va  2 s . co m
    textArea.setEditable(false);
    textArea.setId("text-area-disabled");
    textArea.setText(((USPostalMoneyOrderAccountContractData) paymentAccountContractData).getPostalAddress());
    return gridRow;
}

From source file:nl.mvdr.umvc3replayanalyser.gui.ErrorMessagePopup.java

/**
 * Handles an exception that caused program startup to fail, by showing an error message to the user.
 * //from ww  w  . ja  va2s  .  c  o m
 * @param title
 *            title for the dialog
 * @param errorMessage
 *            error message
 * @param stage
 *            stage in which to show the error message
 * @param exception
 *            exception that caused the error
 */
public static void show(String title, String errorMessage, final Stage stage, Exception exception) {
    log.info("Showing error message dialog to indicate that startup failed.");

    // Create the error dialog programatically without relying on FXML, to minimize the chances of further failure.

    stage.setTitle(title);

    // Error message text.
    Text text = new Text(errorMessage);

    // Text area containing the stack trace. Not visible by default.
    String stackTrace;
    if (exception != null) {
        stackTrace = ExceptionUtils.getStackTrace(exception);
    } else {
        stackTrace = "No more details available.";
    }
    final TextArea stackTraceArea = new TextArea(stackTrace);
    stackTraceArea.setEditable(false);
    stackTraceArea.setVisible(false);

    // Details button for displaying the stack trace.
    Button detailsButton = new Button();
    detailsButton.setText("Details");
    detailsButton.setOnAction(new EventHandler<ActionEvent>() {
        /** {@inheritDoc} */
        @Override
        public void handle(ActionEvent event) {
            log.info("User clicked Details.");
            stackTraceArea.setVisible(!stackTraceArea.isVisible());
        }
    });

    // OK button for closing the dialog.
    Button okButton = new Button();
    okButton.setText("OK");
    okButton.setOnAction(new EventHandler<ActionEvent>() {
        /** {@inheritDoc} */
        @Override
        public void handle(ActionEvent event) {
            log.info("User clicked OK, closing the dialog.");
            stage.close();
        }
    });

    // Horizontal box containing the buttons, to make sure they are always centered.
    HBox buttonsBox = new HBox(5);
    buttonsBox.getChildren().add(detailsButton);
    buttonsBox.getChildren().add(okButton);
    buttonsBox.setAlignment(Pos.CENTER);

    // Layout constraints.
    AnchorPane.setTopAnchor(text, Double.valueOf(5));
    AnchorPane.setLeftAnchor(text, Double.valueOf(5));
    AnchorPane.setRightAnchor(text, Double.valueOf(5));

    AnchorPane.setTopAnchor(stackTraceArea, Double.valueOf(31));
    AnchorPane.setLeftAnchor(stackTraceArea, Double.valueOf(5));
    AnchorPane.setRightAnchor(stackTraceArea, Double.valueOf(5));
    AnchorPane.setBottomAnchor(stackTraceArea, Double.valueOf(36));

    AnchorPane.setLeftAnchor(buttonsBox, Double.valueOf(5));
    AnchorPane.setRightAnchor(buttonsBox, Double.valueOf(5));
    AnchorPane.setBottomAnchor(buttonsBox, Double.valueOf(5));

    AnchorPane root = new AnchorPane();
    root.getChildren().addAll(text, stackTraceArea, buttonsBox);

    stage.setScene(new Scene(root));

    // Use a standard program icon if possible.
    try {
        stage.getIcons().add(Icons.get().getRandomPortrait());
    } catch (IllegalStateException e) {
        log.warn("Failed to load icon for error dialog; proceeding with default JavaFX icon.", e);
    }

    stage.show();

    // Default size should also be the minimum size.
    stage.setMinWidth(stage.getWidth());
    stage.setMinHeight(stage.getHeight());

    log.info("Error dialog displayed.");
}

From source file:org.blockedit.utils.ExceptionDialog.java

/**
 * Create a exception alert that is displayed to the user.
 *
 * @param message The message to show the user
 * @param title The title of the window/*from w ww  .j a  v a2s .c om*/
 * @param header The message header
 * @param exception The exception that triggered this window to be displayed to the user
 * @return A created alert
 */
private static Alert createDialog(String message, String title, String header, Exception exception) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(message);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    String exceptionText = ExceptionUtils.getStackTrace(exception);
    exception.printStackTrace();
    Label label = new Label("The exception stacktrace was:");
    TextArea exceptionArea = new TextArea(
            exceptionText + "\n\n==User Information==\njava.version = " + System.getProperty("java.version")
                    + "\nos.name = " + System.getProperty("os.name") + "\nos.arch = "
                    + System.getProperty("os.arch") + "\nos.version = " + System.getProperty("os.version"));
    exceptionArea.setEditable(false);
    exceptionArea.setWrapText(true);
    exceptionArea.setMaxWidth(UserInformation.getWindowWidth() / 2);
    exceptionArea.setMaxHeight(UserInformation.getWindowHeight() / 2);
    GridPane.setVgrow(exceptionArea, Priority.ALWAYS);
    GridPane.setHgrow(exceptionArea, Priority.ALWAYS);
    GridPane expContent = new GridPane();
    expContent.setMaxWidth(UserInformation.getWindowWidth() / 2);
    expContent.add(label, 0, 0);
    expContent.add(exceptionArea, 0, 1);
    alert.getDialogPane().setExpandableContent(expContent);
    return alert;
}

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/* w w  w  .  j  av a2s .c om*/
        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:net.thirdy.blackmarket.controls.LadderHitsDialog.java

public LadderHitsDialog(ExileToolsHit item) {
    super(AlertType.INFORMATION);
    String title = item.getShop().getSellerAccount()
            + (StringUtils.isBlank(item.getShop().getSellerIGN()) ? LangContants.STRING_EMPTY
                    : (" - " + item.getShop().getSellerIGN()));
    setTitle(title);/*from  w w w.  j a  v a  2s .co  m*/
    setHeaderText("");
    setGraphic(null);
    String json = item.getLadderHit().toString();

    TextArea textArea = new TextArea(json);
    textArea.setEditable(true);
    textArea.setWrapText(false);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMinHeight(400);

    getDialogPane().setContent(textArea);
    initModality(Modality.NONE);
}

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

@Handler
public void handleThrowable(ThrowableEvent event) {
    Platform.runLater(() -> {//from   w w w . j  a  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:com.canoo.dolphin.todo.client.ToDoClient.java

private void showError(String header, String content, Exception e) {
    e.printStackTrace();/*from www  .j  a  v a 2  s  .co  m*/

    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Error");
    alert.setHeaderText(header);
    alert.setContentText(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
    System.exit(-1);
}