private MainApp() /* Extends JFrame */{
DisplayMode displayMode = new DisplayMode(800, 600, 16, 75);
ScreenManager.setFullScreenWindow(displayMode, this);
}
每当我打电话:
JOptionPane.showMessageDialog(MainApp.getInstance(), "Test Message Box");
窗口由于某种原因最小化,然后我必须重新激活它。重新激活窗口后,消息框显示。
当我调用消息框时,有没有办法阻止全屏窗口最小化?
答案 0 :(得分:1)
每当显示模式对话框(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。