java - JavaFX creates Alert dialog which is too small
问题描述
I'm using JavaFX 11.0.1 on Java 11 in Linux (KDE Plasma 5.12.2 on openSUSE Tumbleweed 20190314) to create an Alert
dialog which should look like this:
But most of the time when an Alert
is created and shown it is rendered far too small and looks like this:
About one in five times the Alert
will display correctly. But the rest of the time the unhelpfully small version is shown instead.
There's nothing unusual about the code being used to display this dialog:
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Feature absent");
alert.setContentText(
"Feature \"edit application settings\" has not been finished yet.");
alert.showAndWait();
and I've also tried this advice by adding the following to try to force the size to something useful:
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.getDialogPane().setMinWidth(Region.USE_PREF_SIZE);
but this gives exactly the same behaviour. (Note that even setting numeric values for the minimum width and height still don't fix the problem.)
Is this a known bug in JavaFX 11? Is there some known workaround which I can use to make sure the Alert
dialogs are actually readable?
解决方案
推荐阅读
- ios - 运行命令 shell 脚本 [cp] embed pods framework' 0.2 seconds Command PhaseScriptExecution failed with a nonzero exit code
- jasper-reports - 应用条件格式时子报表周围出现不需要的边框
- python - POST 请求方法在 Django Rest 框架中不起作用
- node.js - 如何使用带有 mocha 的 await 和 ESM 获取 selenium 驱动程序?
- java - 使用表达式委托而不是 Java 类有什么好处?
- dart - 在 Flutter 中定义 const 级别的类
- angular - ngIf 单行 if 语句 | 角 6
- ole - 从 SQL Server 2017 调用 Web 服务 - sp_OAMethod - 无法建立与服务器的连接
- java - 比较方法
- python - 我在 Jupyter 中得到的输出与在 Spyder 中的不同