代码
private MainApp() /* Extends JFrame */{
DisplayMode displayMode = new DisplayMode(800, 600, 16, 75);
ScreenManager.setFullScreenWindow(displayMode, this);
}
问题
每当我打电话时:
JOptionPane.showMessageDialog(MainApp.getInstance(), "Test Message Box");
Window 由于某种原因最小化,然后我必须重新激活它。消息框在我重新激活窗口后显示。
问题
当我调用消息框时,有什么方法可以阻止全屏窗口最小化吗?
最佳答案
每当显示模式对话框(JOptionPane、JFileChooser 等)时,JFrame 都会获得 WINDOW_DEACTIVATED WindowEvent。当您的应用全屏显示时,只需忽略窗口停用:
@Override
protected void processWindowEvent(WindowEvent e)
{
if (e.getID() == WindowEvent.WINDOW_DEACTIVATED)
{
// windowState is set in my set full screen code
if (windowState == WindowState.FULL_SCREEN)
{
return;
}
}
super.processWindowEvent(e);
}
一定要正确设置模态对话框的父级:
fileChooser.showOpenDialog(this);
“this”是最顶层的 JPanel、JInternalFrame 或 JFrame。
关于java - 当 JOptionPane.showMessageDialog 时停止全屏窗口最小化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9179493/