警报标题中的奇怪字符,可能是编码问题?
Strange characters in the title of an alert, possible encoding issue?
我正在尝试编写一个简单的方法来显示警告对话框并要求用户对我的电子邮件提供反馈。
我的方法:
public static void showExceptionDialog(Exception exception) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
exception.printStackTrace(printWriter);
String exceptionText = stringWriter.toString();
try {
VBox content = FXMLLoader.load(Dialogs.class.getResource("/org/flycraft/minecraft/droplauncher/exception_dialog_content.fxml"));
TextArea exceptionTextArea = (TextArea) content.lookup("#exception_text_area");
exceptionTextArea.setText(exceptionText);
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Ошибка");
alert.setHeaderText("Что-то пошло не так");
alert.getDialogPane().setContent(content);
alert.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
但在真实对话中我看到:
这是一个错误,还是我不明白的地方?
是的,已修复。我使用 this 插件通过 gradle 构建 JavaFX 应用程序。所以我刚刚将这一行添加到我的 build.gradle:
compileJava.options.encoding = 'UTF-8'
我正在尝试编写一个简单的方法来显示警告对话框并要求用户对我的电子邮件提供反馈。
我的方法:
public static void showExceptionDialog(Exception exception) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
exception.printStackTrace(printWriter);
String exceptionText = stringWriter.toString();
try {
VBox content = FXMLLoader.load(Dialogs.class.getResource("/org/flycraft/minecraft/droplauncher/exception_dialog_content.fxml"));
TextArea exceptionTextArea = (TextArea) content.lookup("#exception_text_area");
exceptionTextArea.setText(exceptionText);
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Ошибка");
alert.setHeaderText("Что-то пошло не так");
alert.getDialogPane().setContent(content);
alert.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
但在真实对话中我看到:
这是一个错误,还是我不明白的地方?
是的,已修复。我使用 this 插件通过 gradle 构建 JavaFX 应用程序。所以我刚刚将这一行添加到我的 build.gradle:
compileJava.options.encoding = 'UTF-8'