List of usage examples for javafx.scene.control TextArea TextArea
public TextArea(String text)
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 ww .j av a 2s. c om*/ 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:Main.java
@Override public void start(Stage stage) { Parameters p = this.getParameters(); Map<String, String> namedParams = p.getNamed(); List<String> unnamedParams = p.getUnnamed(); List<String> rawParams = p.getRaw(); String paramStr = "Named Parameters: " + namedParams + "\n" + "Unnamed Parameters: " + unnamedParams + "\n" + "Raw Parameters: " + rawParams; TextArea ta = new TextArea(paramStr); Group root = new Group(ta); stage.setScene(new Scene(root)); stage.setTitle(""); stage.show();//from ww w. ja v a2s. c om }
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 2 s .c o 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:nl.mvdr.umvc3replayanalyser.gui.ErrorMessagePopup.java
/** * Handles an exception that caused program startup to fail, by showing an error message to the user. * //from w w w . j ava 2 s . 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: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 w w. j av 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:eu.over9000.skadi.ui.dialogs.UpdateAvailableDialog.java
public UpdateAvailableDialog(RemoteVersionResult newVersion) { super(AlertType.INFORMATION, null, UPDATE_BUTTON_TYPE, IGNORE_BUTTON_TYPE); this.setTitle("Update available"); this.setHeaderText(newVersion.getVersion() + " is available"); Label lbChangeLog = new Label("Changelog:"); TextArea taChangeLog = new TextArea(newVersion.getChangeLog()); taChangeLog.setEditable(false);/*from w w w .j a va2 s . c o m*/ taChangeLog.setWrapText(true); Label lbSize = new Label("Size:"); Label lbSizeValue = new Label(FileUtils.byteCountToDisplaySize(newVersion.getSize())); Label lbPublished = new Label("Published"); Label lbPublishedValue = new Label( ZonedDateTime.parse(newVersion.getPublished()).format(DateTimeFormatter.RFC_1123_DATE_TIME)); final GridPane grid = new GridPane(); RowConstraints vAlign = new RowConstraints(); vAlign.setValignment(VPos.TOP); grid.getRowConstraints().add(vAlign); grid.setHgap(10); grid.setVgap(10); grid.add(lbChangeLog, 0, 0); grid.add(taChangeLog, 1, 0); grid.add(lbPublished, 0, 1); grid.add(lbPublishedValue, 1, 1); grid.add(lbSize, 0, 2); grid.add(lbSizeValue, 1, 2); this.getDialogPane().setContent(grid); }
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 ww w . ja v a2 s .com*/ * @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:Main.java
public VBox createPage(int pageIndex) { VBox box = new VBox(5); int page = pageIndex * itemsPerPage(); for (int i = page; i < page + itemsPerPage(); i++) { TextArea text = new TextArea(textPages[i]); text.setWrapText(true);/*from ww w. j a v a 2 s . c o m*/ box.getChildren().add(text); } return box; }
From source file:com.scndgen.legends.windows.WindowAbout.java
public WindowAbout() { super(StageStyle.UNDECORATED); try {//from w ww .j a va 2 s . c om about = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtAbout.txt"), Charset.defaultCharset()); licenseText = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtLicense.txt"), Charset.defaultCharset()); changeLog = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtChangelog.txt"), Charset.defaultCharset()); sourceCode = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtSourceCode.txt"), Charset.defaultCharset()); } catch (Exception ex) { ex.printStackTrace(System.err); } txtAbout = new TextArea(""); txtAbout.setText(about); txtAbout.setEditable(false); txtAbout.setWrapText(true); scrlAbout = new ScrollPane(txtAbout); txtLicense = new TextArea(""); txtLicense.setText(licenseText); txtLicense.setEditable(false); txtLicense.setWrapText(true); scrlLicense = new ScrollPane(txtLicense); txtChangeLog = new TextArea(""); txtChangeLog.setText(changeLog); txtChangeLog.setEditable(false); txtChangeLog.setWrapText(true); scrlChangeLog = new ScrollPane(txtChangeLog); txtSourceCode = new TextArea(""); txtSourceCode.setText(sourceCode); txtSourceCode.setEditable(false); txtSourceCode.setWrapText(true); scrlSourceCode = new ScrollPane(txtSourceCode); Tab tabAbout = new Tab("About"); tabAbout.setClosable(false); Tab tabLicense = new Tab("License"); tabLicense.setClosable(false); Tab tabDevelop = new Tab("Develop"); tabDevelop.setClosable(false); Tab tabChangelog = new Tab("Changelog"); tabChangelog.setClosable(false); tabAbout.setContent(scrlAbout); tabLicense.setContent(scrlLicense); tabDevelop.setContent(scrlSourceCode); tabChangelog.setContent(scrlChangeLog); tabPane = new TabPane(); tabPane.getTabs().add(tabAbout); tabPane.getTabs().add(tabLicense); tabPane.getTabs().add(tabChangelog); tabPane.getTabs().add(tabDevelop); btnOk = new Button("OK"); btnOk.setOnAction(event -> { close(); }); VBox vBox = new VBox(); vBox.setSpacing(4); vBox.getChildren().add(tabPane); vBox.getChildren().add(btnOk); setTitle(Language.get().get(57)); setScene(new Scene(vBox)); setResizable(false); initModality(Modality.APPLICATION_MODAL); show(); }
From source file:com.canoo.dolphin.todo.client.ToDoClient.java
private void showError(String header, String content, Exception e) { e.printStackTrace();/*from w w w. j a v a 2 s . c o 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); }