java - 模态 JDialog 隐藏在 macOS Big Sur 上的主框架后面
问题描述
单击框架上的某个位置时,模态对话框隐藏在主框架后面。
主框架被阻止(正确),只有通过单击主框架标题栏才能将对话框带回前面。
在 Mac mini(2018,Intel Core i5,macOS Big Sur 11.1)上测试
使用 AdoptOpenJDK 8(HotSpot 和 OpenJ9)、AdoptOpenJDK 11、AdoptOpenJDK 15、Amazon Corretto 15 和 Oracle JDK 16 进行了测试。
其他人可以重现这个问题吗?
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new FlowLayout());
JButton button = new JButton("Open modal dialog");
button.addActionListener(e -> actionOpenDialog(frame));
frame.getContentPane().add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 450);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private static void actionOpenDialog(JFrame frame) {
JDialog dialog = new JDialog(/* parent */ frame, /* modal */ true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setSize(300, 200);
dialog.setLocationRelativeTo(dialog.getParent());
dialog.setVisible(true);
}
}
错误报告:JDK-8263801。
解决方案
推荐阅读
- c# - 如何将天空盒添加到相机并使用图层仅在主菜单中显示?
- unity3d - Unity 已停止工作 / DirectX10 卡 / D3D10Level9.dll 导致访问冲突
- php - Laravel 将可选的 url 参数视为强制性的
- javascript - PHP 中如何进行数学运算?
- python - Python IDLE,导入 XLRD,在调试模式下产生错误:AttributeError: '_ModuleLock' object has no attribute 'name'
- c# - ASP.NET Core Identity 3.1:UserManager.RemoveFromRoleAsync 总是返回 UserNotInRole
- command-line - 为什么我在启动cmder时不断获取所有系统路径?
- jquery - 用户 jquery 用另一个通用替换一个单词,但忽略 html 标签、属性、脚本标签等
- android-studio - Android Studio 更新后。无法解析 POM,无法解析配置 ':app:_internal_aapt2_binary' 的所有文件
- python - 在模块之间传递变量