javafx.scene.control.TextArea#setMaxWidth ( )源码实例Demo

下面列出了javafx.scene.control.TextArea#setMaxWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: qiniu   文件: DialogUtils.java
public static Optional<ButtonType> showException(String header, Exception e) {
    // 获取一个警告对象
    Alert alert = getAlert(header, "错误信息追踪:", AlertType.ERROR);
    // 打印异常信息
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    e.printStackTrace(printWriter);
    String exception = stringWriter.toString();
    // 显示异常信息
    TextArea textArea = new TextArea(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);
    GridPane gridPane = new GridPane();
    gridPane.setMaxWidth(Double.MAX_VALUE);
    gridPane.add(textArea, 0, 0);
    alert.getDialogPane().setExpandableContent(gridPane);
    return alert.showAndWait();
}
 
源代码2 项目: xltsearch   文件: DetailedAlert.java
void setDetailsText(String details) {
    GridPane content = new GridPane();
    content.setMaxHeight(Double.MAX_VALUE);

    Label label = new Label("Details:");
    TextArea textArea = new TextArea(details);
    textArea.setEditable(false);
    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);

    content.add(label, 0, 0);
    content.add(textArea, 0, 1);

    this.getDialogPane().setExpandableContent(content);
    // work around DialogPane expandable content resize bug
    this.getDialogPane().expandedProperty().addListener((ov, oldValue, newValue) -> {
        Platform.runLater(() -> {
            this.getDialogPane().requestLayout();
            this.getDialogPane().getScene().getWindow().sizeToScene();
        });
    });
}
 
源代码3 项目: Library-Assistant   文件: AlertMaker.java
public static void showErrorMessage(Exception ex, String title, String content) {
    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle("Error occured");
    alert.setHeaderText(title);
    alert.setContentText(content);

    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);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
}
 
源代码4 项目: phoenicis   文件: StepRepresentationLicence.java
@Override
protected void drawStepContent() {
    super.drawStepContent();

    TextArea licenceWidget = new TextArea(licenceText);
    licenceWidget.setLayoutX(10);
    licenceWidget.setLayoutY(100);
    licenceWidget.setMinWidth(700);
    licenceWidget.setMaxWidth(700);
    licenceWidget.setMinHeight(308);
    licenceWidget.setMaxHeight(308);
    licenceWidget.setEditable(false);

    CheckBox confirmWidget = new CheckBox(tr("I agree"));
    confirmWidget.setOnAction(event -> {
        isAgree = !isAgree;
        confirmWidget.setSelected(isAgree);
        setNextButtonEnabled(isAgree);
    });
    confirmWidget.setLayoutX(10);
    confirmWidget.setLayoutY(418);
    setNextButtonEnabled(false);

    this.addToContentPane(licenceWidget);
    this.addToContentPane(confirmWidget);
}
 
源代码5 项目: milkman   文件: ExceptionDialog.java
public ExceptionDialog(Throwable ex) {
	super(AlertType.ERROR);
	setTitle("Exception");
	setHeaderText("Exception during startup of application");
	setContentText(ex.getClass().getName() + ": " + ex.getMessage());


	// 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.
	getDialogPane().setExpandableContent(expContent);
}
 
源代码6 项目: Weather-Forecast   文件: JFxBuilder.java
private void createAlertDialog(DialogObject dialog) {
    Alert alert = new Alert(dialog.getType());
    alert.setTitle(dialog.getTitle());
    alert.setHeaderText(dialog.getHeader());
    alert.setContentText(dialog.getContent());

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK) {
        System.exit(0);
    } else {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        dialog.getexception().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();
    }
}
 
源代码7 项目: Motion_Profile_Generator   文件: AlertFactory.java
public static Alert createExceptionAlert( Exception e, String msg )
{
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Exception Dialog");
    alert.setHeaderText("Whoops!");
    alert.setContentText(msg);

    // Create expandable Exception.
    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);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(expContent);

    return alert;
}
 
源代码8 项目: DeskChan   文件: App.java
static void showThrowable(String sender, String className, String message, List<StackTraceElement> stacktrace) {
	if (!Main.getProperties().getBoolean("error-alerting", true)) return;

	Alert alert = new Alert(Alert.AlertType.ERROR);
	((Stage) alert.getDialogPane().getScene().getWindow()).getIcons().add(new Image(App.ICON_URL.toString()));

	alert.setTitle(Main.getString("error"));
	alert.initModality(Modality.WINDOW_MODAL);
	alert.setHeaderText(className + " " + Main.getString("caused-by") + " " + sender);
	alert.setContentText(message);
	StringBuilder exceptionText = new StringBuilder ();
	for (Object item : stacktrace)
		exceptionText.append((item != null ? item.toString() : "null") + "\n");

	TextArea textArea = new TextArea(exceptionText.toString());
	textArea.setEditable(false);
	textArea.setWrapText(true);
	textArea.setMaxWidth(Double.MAX_VALUE);
	textArea.setMaxHeight(Double.MAX_VALUE);

	CheckBox checkBox = new CheckBox(Main.getString("enable-error-alert"));
	checkBox.setSelected(Main.getProperties().getBoolean("error-alerting", true));
	checkBox.selectedProperty().addListener((obs, oldValue, newValue) -> {
		Main.getProperties().put("error-alerting", newValue);
	});

	BorderPane pane = new BorderPane();
	pane.setTop(checkBox);
	pane.setCenter(textArea);

	alert.getDialogPane().setExpandableContent(pane);
	alert.show();
}
 
源代码9 项目: ApkToolPlus   文件: DialogPlus.java
/**
 *  显示Exception的Dialog
 *
 * @param ex  异常
 */
public static void exception(Exception ex){
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Exception Dialog");
    alert.setHeaderText("Look, an Exception Dialog");
    alert.setContentText("Could not find file blabla.txt!");

    //Exception ex = new FileNotFoundException("Could not find file blabla.txt");

    // 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();
}
 
源代码10 项目: Lipi   文件: ExceptionAlerter.java
public static void showException(Exception e) {

        if (e != null) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("Exception Alert!");
            alert.setHeaderText("An Exception was thrown.");
            alert.setContentText(e.getMessage());

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

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

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

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

            GridPane expContent = new GridPane();
            expContent.setMaxWidth(Double.MAX_VALUE);
            expContent.add(stackTraceHeaderLabel, 0, 0);
            expContent.add(stackTraceTextArea, 0, 1);

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

            alert.showAndWait();
        }
    }
 
源代码11 项目: Library-Assistant   文件: AlertMaker.java
public static void showErrorMessage(Exception ex) {
    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle("Error occured");
    alert.setHeaderText("Error Occured");
    alert.setContentText(ex.getLocalizedMessage());

    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);

    alert.getDialogPane().setExpandableContent(expContent);

    styleAlert(alert);
    alert.showAndWait();
}
 
源代码12 项目: GitFx   文件: GitFxDialog.java
@Override
public void gitExceptionDialog(String title, String header, String content, Exception e) {

    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle(title);
    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("Exception stack trace:");

    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();
}
 
源代码13 项目: paintera   文件: LockFileAlreadyExistsDialog.java
public static void showDialog(final LockFile.UnableToCreateLock exception)
{
	final Alert alert = new Alert(AlertType.ERROR);
	alert.setTitle("Paintera");
	alert.setHeaderText("Unable to create lock file.");

	final Label instructions = new Label(
			"If no other Paintera instance is accessing the same project please delete lock file and try to " +
					"restart Paintera.");
	instructions.setWrapText(true);

	final GridPane  content      = new GridPane();
	final Label     fileLabel    = new Label("Lock File");
	final Label     messageLabel = new Label("Message");
	final TextField fileField    = new TextField(exception.getLockFile().getAbsolutePath());
	final TextField messageField = new TextField(exception.getMessage());
	fileField.setTooltip(new Tooltip(fileField.getText()));
	messageField.setTooltip(new Tooltip(messageField.getText()));

	fileField.setEditable(false);
	messageField.setEditable(false);

	GridPane.setHgrow(fileField, Priority.ALWAYS);
	GridPane.setHgrow(messageField, Priority.ALWAYS);

	content.add(fileLabel, 0, 0);
	content.add(messageLabel, 0, 1);
	content.add(fileField, 1, 0);
	content.add(messageField, 1, 1);

	final VBox contentBox = new VBox(instructions, content);

	alert.getDialogPane().setContent(contentBox);

	final StringWriter stringWriter = new StringWriter();
	exception.printStackTrace(new PrintWriter(stringWriter));
	final String   exceptionText = stringWriter.toString();
	final TextArea textArea      = new TextArea(exceptionText);
	textArea.setEditable(false);
	textArea.setWrapText(true);

	LOG.trace("Exception text (length={}): {}", exceptionText.length(), exceptionText);

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

	//		final GridPane expandableContent = new GridPane();
	//		expandableContent.setMaxWidth( Double.MAX_VALUE );
	//
	//		expandableContent.add( child, columnIndex, rowIndex );

	alert.getDialogPane().setExpandableContent(textArea);

	//		alert.setResizable( true );
	alert.showAndWait();
}