List of usage examples for javafx.scene.control TextArea setMaxHeight
public final void setMaxHeight(double value)
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);//from w w w.j a va 2 s.co 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: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. jav 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:com.canoo.dolphin.todo.client.ToDoClient.java
private void showError(String header, String content, Exception e) { e.printStackTrace();/*from ww w . jav a2 s.com*/ 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); }
From source file:io.bitsquare.gui.components.paymentmethods.CashDepositForm.java
@Override public void addFormForDisplayAccount() { gridRowFrom = gridRow;//from w ww. j a v a 2s. c o m String countryCode = cashDepositAccountContractData.getCountryCode(); addLabelTextField(gridPane, gridRow, "Account name:", paymentAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); addLabelTextField(gridPane, ++gridRow, "Payment method:", BSResources.get(paymentAccount.getPaymentMethod().getId())); addLabelTextField(gridPane, ++gridRow, "Country:", getCountryBasedPaymentAccount().getCountry() != null ? getCountryBasedPaymentAccount().getCountry().name : ""); addLabelTextField(gridPane, ++gridRow, "Currency:", paymentAccount.getSingleTradeCurrency().getNameAndCode()); addAcceptedBanksForDisplayAccount(); addHolderNameAndIdForDisplayAccount(); addLabelTextField(gridPane, ++gridRow, "Account holder email:", cashDepositAccountContractData.getHolderEmail()); if (BankUtil.isBankNameRequired(countryCode)) addLabelTextField(gridPane, ++gridRow, "Bank name:", cashDepositAccountContractData.getBankName()).second.setMouseTransparent(false); if (BankUtil.isBankIdRequired(countryCode)) addLabelTextField(gridPane, ++gridRow, BankUtil.getBankIdLabel(countryCode), cashDepositAccountContractData.getBankId()).second.setMouseTransparent(false); if (BankUtil.isBranchIdRequired(countryCode)) addLabelTextField(gridPane, ++gridRow, BankUtil.getBranchIdLabel(countryCode), cashDepositAccountContractData.getBranchId()).second.setMouseTransparent(false); if (BankUtil.isAccountNrRequired(countryCode)) addLabelTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(countryCode), cashDepositAccountContractData.getAccountNr()).second.setMouseTransparent(false); if (BankUtil.isAccountTypeRequired(countryCode)) addLabelTextField(gridPane, ++gridRow, BankUtil.getAccountTypeLabel(countryCode), cashDepositAccountContractData.getAccountType()).second.setMouseTransparent(false); String requirements = cashDepositAccountContractData.getRequirements(); boolean showRequirements = requirements != null && !requirements.isEmpty(); if (showRequirements) { TextArea textArea = addLabelTextArea(gridPane, ++gridRow, "Extra requirements:", "").second; textArea.setMinHeight(30); textArea.setMaxHeight(30); textArea.setEditable(false); textArea.setId("text-area-disabled"); textArea.setText(requirements); } addAllowedPeriod(); }
From source file:frontend.GUIController.java
@FXML void showAbout(ActionEvent event) { /*Dialogs.create()/*from ww w.ja v a 2s. c o m*/ .title("About") .message(getLicense()) .showInformation();*/ Alert alert = new Alert(AlertType.INFORMATION); alert.initOwner(stage); alert.initModality(Modality.APPLICATION_MODAL); alert.setTitle("SAIL 1.1: About"); alert.setHeaderText("SAIL 1.1 details"); alert.setContentText("SAIL 1.1"); Label label = new Label("SAIL License details:"); TextArea textArea = new TextArea(getLicense()); 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); // Set expandable Exception into the dialog pane. alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait(); }
From source file:io.bitsquare.gui.components.paymentmethods.CashDepositForm.java
@Override public void addFormForAddAccount() { gridRowFrom = gridRow + 1;/* www .j a v a 2 s . co m*/ Tuple3<Label, ComboBox, ComboBox> tuple3 = addLabelComboBoxComboBox(gridPane, ++gridRow, "Country:"); ComboBox<Region> regionComboBox = tuple3.second; regionComboBox.setPromptText("Select region"); regionComboBox.setConverter(new StringConverter<Region>() { @Override public String toString(Region region) { return region.name; } @Override public Region fromString(String s) { return null; } }); regionComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllRegions())); ComboBox<Country> countryComboBox = tuple3.third; countryComboBox.setVisibleRowCount(15); countryComboBox.setDisable(true); countryComboBox.setPromptText("Select country"); countryComboBox.setConverter(new StringConverter<Country>() { @Override public String toString(Country country) { return country.name + " (" + country.code + ")"; } @Override public Country fromString(String s) { return null; } }); countryComboBox.setOnAction(e -> { Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem(); if (selectedItem != null) { getCountryBasedPaymentAccount().setCountry(selectedItem); String countryCode = selectedItem.code; TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode); paymentAccount.setSingleTradeCurrency(currency); currencyComboBox.setDisable(false); currencyComboBox.getSelectionModel().select(currency); bankIdLabel.setText(BankUtil.getBankIdLabel(countryCode)); branchIdLabel.setText(BankUtil.getBranchIdLabel(countryCode)); accountNrLabel.setText(BankUtil.getAccountNrLabel(countryCode)); accountTypeLabel.setText(BankUtil.getAccountTypeLabel(countryCode)); bankNameInputTextField.setText(""); bankIdInputTextField.setText(""); branchIdInputTextField.setText(""); accountNrInputTextField.setText(""); accountTypeComboBox.getSelectionModel().clearSelection(); accountTypeComboBox .setItems(FXCollections.observableArrayList(BankUtil.getAccountTypeValues(countryCode))); if (BankUtil.useValidation(countryCode) && !validatorsApplied) { validatorsApplied = true; if (useHolderID) holderIdInputTextField.setValidator(inputValidator); bankNameInputTextField.setValidator(inputValidator); bankIdInputTextField.setValidator(new BankIdValidator(countryCode)); branchIdInputTextField.setValidator(new BranchIdValidator(countryCode)); accountNrInputTextField.setValidator(new AccountNrValidator(countryCode)); } else { validatorsApplied = false; if (useHolderID) holderIdInputTextField.setValidator(null); bankNameInputTextField.setValidator(null); bankIdInputTextField.setValidator(null); branchIdInputTextField.setValidator(null); accountNrInputTextField.setValidator(null); } holderNameInputTextField.resetValidation(); holderEmailInputTextField.resetValidation(); bankNameInputTextField.resetValidation(); bankIdInputTextField.resetValidation(); branchIdInputTextField.resetValidation(); accountNrInputTextField.resetValidation(); boolean requiresHolderId = BankUtil.isHolderIdRequired(countryCode); if (requiresHolderId) { holderNameInputTextField.minWidthProperty().unbind(); holderNameInputTextField.setMinWidth(300); } else { holderNameInputTextField.minWidthProperty().bind(currencyComboBox.widthProperty()); } if (useHolderID) { if (!requiresHolderId) holderIdInputTextField.setText(""); holderIdInputTextField.resetValidation(); holderIdInputTextField.setVisible(requiresHolderId); holderIdInputTextField.setManaged(requiresHolderId); holderIdLabel.setText(BankUtil.getHolderIdLabel(countryCode)); holderIdLabel.setVisible(requiresHolderId); holderIdLabel.setManaged(requiresHolderId); } boolean bankNameRequired = BankUtil.isBankNameRequired(countryCode); bankNameTuple.first.setVisible(bankNameRequired); bankNameTuple.first.setManaged(bankNameRequired); bankNameInputTextField.setVisible(bankNameRequired); bankNameInputTextField.setManaged(bankNameRequired); boolean bankIdRequired = BankUtil.isBankIdRequired(countryCode); bankIdTuple.first.setVisible(bankIdRequired); bankIdTuple.first.setManaged(bankIdRequired); bankIdInputTextField.setVisible(bankIdRequired); bankIdInputTextField.setManaged(bankIdRequired); boolean branchIdRequired = BankUtil.isBranchIdRequired(countryCode); branchIdTuple.first.setVisible(branchIdRequired); branchIdTuple.first.setManaged(branchIdRequired); branchIdInputTextField.setVisible(branchIdRequired); branchIdInputTextField.setManaged(branchIdRequired); boolean accountNrRequired = BankUtil.isAccountNrRequired(countryCode); accountNrTuple.first.setVisible(accountNrRequired); accountNrTuple.first.setManaged(accountNrRequired); accountNrInputTextField.setVisible(accountNrRequired); accountNrInputTextField.setManaged(accountNrRequired); boolean accountTypeRequired = BankUtil.isAccountTypeRequired(countryCode); accountTypeTuple.first.setVisible(accountTypeRequired); accountTypeTuple.first.setManaged(accountTypeRequired); accountTypeTuple.second.setVisible(accountTypeRequired); accountTypeTuple.second.setManaged(accountTypeRequired); updateFromInputs(); onCountryChanged(); } }); regionComboBox.setOnAction(e -> { Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem(); if (selectedItem != null) { countryComboBox.setDisable(false); countryComboBox.setItems( FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem))); } }); currencyComboBox = addLabelComboBox(gridPane, ++gridRow, "Currency:").second; currencyComboBox.setPromptText("Select currency"); currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies())); currencyComboBox.setOnAction(e -> { TradeCurrency selectedItem = currencyComboBox.getSelectionModel().getSelectedItem(); FiatCurrency defaultCurrency = CurrencyUtil .getCurrencyByCountryCode(countryComboBox.getSelectionModel().getSelectedItem().code); if (!defaultCurrency.equals(selectedItem)) { new Popup<>().warning( "Are you sure you want to choose a currency other than the country's default currency?") .actionButtonText("Yes").onAction(() -> { paymentAccount.setSingleTradeCurrency(selectedItem); autoFillNameTextField(); }).closeButtonText("No, restore default currency") .onClose(() -> currencyComboBox.getSelectionModel().select(defaultCurrency)).show(); } else { paymentAccount.setSingleTradeCurrency(selectedItem); autoFillNameTextField(); } }); currencyComboBox.setConverter(new StringConverter<TradeCurrency>() { @Override public String toString(TradeCurrency currency) { return currency.getNameAndCode(); } @Override public TradeCurrency fromString(String string) { return null; } }); currencyComboBox.setDisable(true); addAcceptedBanksForAddAccount(); addHolderNameAndId(); bankNameTuple = addLabelInputTextField(gridPane, ++gridRow, "Bank name:"); bankNameInputTextField = bankNameTuple.second; bankNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setBankName(newValue); updateFromInputs(); }); bankIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBankIdLabel("")); bankIdLabel = bankIdTuple.first; bankIdInputTextField = bankIdTuple.second; bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setBankId(newValue); updateFromInputs(); }); branchIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchIdLabel("")); branchIdLabel = branchIdTuple.first; branchIdInputTextField = branchIdTuple.second; branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setBranchId(newValue); updateFromInputs(); }); accountNrTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel("")); accountNrLabel = accountNrTuple.first; accountNrInputTextField = accountNrTuple.second; accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setAccountNr(newValue); updateFromInputs(); }); accountTypeTuple = addLabelComboBox(gridPane, ++gridRow, ""); accountTypeLabel = accountTypeTuple.first; accountTypeComboBox = accountTypeTuple.second; accountTypeComboBox.setPromptText("Select account type"); accountTypeComboBox.setOnAction(e -> { if (BankUtil.isAccountTypeRequired(cashDepositAccountContractData.getCountryCode())) { cashDepositAccountContractData .setAccountType(accountTypeComboBox.getSelectionModel().getSelectedItem()); updateFromInputs(); } }); TextArea requirementsTextArea = addLabelTextArea(gridPane, ++gridRow, "Extra requirements:", "").second; requirementsTextArea.setMinHeight(30); requirementsTextArea.setMaxHeight(30); requirementsTextArea.textProperty().addListener((ov, oldValue, newValue) -> { cashDepositAccountContractData.setRequirements(newValue); updateFromInputs(); }); addAllowedPeriod(); addAccountNameTextFieldWithAutoFillCheckBox(); updateFromInputs(); }
From source file:acmi.l2.clientmod.l2smr.Controller.java
private void onException(String text, Throwable ex) { ex.printStackTrace();//from ww w . ja v a 2s. c o m Platform.runLater(() -> { if (SHOW_STACKTRACE) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText(null); alert.setContentText(text); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); String exceptionText = sw.toString(); Label label = new Label("Exception stacktrace:"); 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(); } else { //noinspection ThrowableResultOfMethodCallIgnored Throwable t = getTop(ex); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(t.getClass().getSimpleName()); alert.setHeaderText(text); alert.setContentText(t.getMessage()); 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);// w ww . j av a 2 s . c o m // 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: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//w ww . jav a2s . c o m * @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:pah9qdmoviereviews.MovieReviewsFXMLController.java
public void displayExceptionAlert(Exception ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Exception"); alert.setHeaderText("An Exception Occurred!"); alert.setContentText(//from w ww. j a v a 2 s.c o m "An exception occurred. View the exception information below by clicking Show Details."); // Create expandable Exception. StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.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); // Set expandable Exception into the dialog pane. alert.getDialogPane().setExpandableContent(expContent); alert.showAndWait(); }