本文整理汇总了Java中javafx.scene.control.TextArea.setWrapText方法的典型用法代码示例。如果您正苦于以下问题:Java TextArea.setWrapText方法的具体用法?Java TextArea.setWrapText怎么用?Java TextArea.setWrapText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TextArea
的用法示例。
在下文中一共展示了TextArea.setWrapText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createExpandableContent
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
private static GridPane createExpandableContent(String content) {
Label label = new Label("Exception stacktrace");
TextArea textArea = new TextArea(content);
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);
return expContent;
}
示例2: build
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
@Override
public AlertDialog build() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
TextArea textArea = new TextArea();
GridPane expContent = new GridPane();
Label label = new Label("Stacktrace:");
label.setTextFill(Utils.getDefaultTextColor());
initOwner(ownerStage);
setTitle(title);
setHeaderText(header);
setContentText(message);
exception.printStackTrace(pw);
String exceptionText = sw.toString();
textArea.setText(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);
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
getDialogPane().setExpandableContent(expContent);
return this;
}
示例3: initUI
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
@PostConstruct
void initUI(BorderPane pane) {
try {
Button EnterButton = new Button();
TextArea textbox = new TextArea();
EnterButton.setText("Send Data");
EnterButton.setOnAction((event) -> {
String tmp = textbox.getText();
Helper.handleButton(tmp);
});
textbox.setMaxWidth(500);
textbox.setMaxHeight(100);
textbox.setWrapText(true);
textbox.setText("Type your sentence here");
pane.setLeft(EnterButton);
pane.setCenter(textbox);
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例4: createExceptionTextArea
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
protected static GridPane createExceptionTextArea(Throwable errorToDisplay) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
errorToDisplay.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);
return expContent;
}
示例5: showException
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
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();
}
示例6: showThrowable
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
/** Show error dialog. **/
static void showThrowable(Window parent, Throwable e) {
Main.log(e);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.initOwner(parent);
alert.initModality(Modality.WINDOW_MODAL);
alert.setHeaderText(e.getClass().getName());
alert.setContentText(e.getMessage());
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
String exceptionText = stringWriter.toString();
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
alert.getDialogPane().setExpandableContent(textArea);
alert.showAndWait();
}
示例7: show
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
void show() {
textAreaLog = new TextArea();
textAreaLog.setWrapText(true);
textAreaLog.setEditable(false);
textAreaLog.setPrefColumnCount(50);
textAreaLog.setPrefRowCount(30);
root = new FlowPane();
root.setAlignment(Pos.BASELINE_CENTER);
root.getChildren().add(textAreaLog);
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
}
示例8: exceptionAlert
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
public static ViewerAlert exceptionAlert(Throwable ex) {
ViewerAlert alert = new ViewerAlert(AlertType.ERROR);
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.setFont(FontUtils.textFont);
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);
return alert;
}
示例9: ExceptionMessage
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
public ExceptionMessage(String message, Exception ex) {
super(AlertType.ERROR);
setTitle("Exception");
setHeaderText("Encountered an Exception");
setContentText(message);
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);
getDialogPane().setExpandableContent(expContent);
}
示例10: createAlertDialog
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
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();
}
}
示例11: showDetailedErrorAlert
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
public static void showDetailedErrorAlert(String title, String content, String detaildescription, String details) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(content);
TextArea textArea = new TextArea(details);
textArea.setEditable(false);
textArea.setWrapText(true);
Label label = new Label(detaildescription);
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();
}
示例12: showErrorDialog
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
static void showErrorDialog(Throwable ex) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error!");
alert.setHeaderText(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(false);
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().setContent(expContent);
alert.showAndWait();
ex.printStackTrace();
}
示例13: showException
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
public static Alert showException(String message, Exception ex) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Exception");
alert.setHeaderText("Encountered an Exception");
alert.setContentText(message);
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);
return alert;
}
示例14: createAlert
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
/**
* Create an alert with a given type, title, desciption, content text and expandable content.
*
* @param type The type of the alert
* @param title The title of the alert
* @param description The description in the alert
* @param contentText The content text for the alert
* @param expandableContent The expandable content in the alert. This parameter may be null
* @return The created alert
*/
public static Alert createAlert(Alert.AlertType type, String title, String description,
String contentText, String expandableContent) {
Alert alert = new Alert(type);
alert.setTitle(title);
alert.setHeaderText(description);
alert.setContentText(contentText);
TextArea textArea = new TextArea(expandableContent);
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);
if (expandableContent != null && expandableContent.length() > 0) {
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
if (type.equals(Alert.AlertType.ERROR)) {
Label label = new Label("Stack trace:");
expContent.add(label, 0, 0);
}
expContent.add(textArea, 0, 1);
alert.getDialogPane().setExpandableContent(expContent);
}
if (type.equals(Alert.AlertType.ERROR) && expandableContent != null) {
System.err.println(contentText);
System.err.println(expandableContent);
}
alert.getDialogPane().setId("AlertDialogPane_" + type.toString());
return alert;
}
示例15: showExceptionDialog
import javafx.scene.control.TextArea; //导入方法依赖的package包/类
public static void showExceptionDialog (String title, String content, Throwable e) {
//Source: http://code.makery.ch/blog/javafx-dialogs-official/
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(content);
// 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);
alert.showAndWait();
}