我正在为 Windows 专门编写 JavaFX 应用,其中应用需要崩溃并生成通用"Application has Stopped Working"
错误对话< / strong>当客户端使用盗版序列密钥激活应用时,看到here。
这可能吗?
答案 0 :(得分:1)
您可以将Alert类与ERROR警报类型一起使用 以下是一个工作示例:
<强> MyApplication.java 强>
FileReader fileReader = new FileReader(this);
final Map<String, String> numberDescMap = fileReader.ExcelFileReader();
<强> ApplicationError.java 强>
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
try {
// do something
throw new RuntimeException();
} catch (Exception ex) {
displayApplicationError();
}
}
private void displayApplicationError() {
Platform.runLater(() -> {
new ApplicationError().start(new Stage());
Platform.exit();
});
}
警报在Windows上具有原生外观,您可以找到更多示例here。