从最小化时停止JOptionPane.showMessageDialog全屏窗口? [英] Stop Fullscreen Window from minimizing when JOptionPane.showMessageDialog?

查看:326
本文介绍了从最小化时停止JOptionPane.showMessageDialog全屏窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private MainApp() /* Extends JFrame */{
    DisplayMode displayMode = new DisplayMode(800, 600, 16, 75);
    ScreenManager.setFullScreenWindow(displayMode, this);
}

问题

每当我打电话:

JOptionPane.showMessageDialog(MainApp.getInstance(), "Test Message Box");

窗口由于某种原因减少的话,我必须重新激活它。消息框显示了我之后重新激活窗口。

The Window minimizes for some reason, then I have to re-activate it. The Message Box shows after I re-activate the Window.

有没有办法从减少停止全屏窗口当我打电话的消息框?

Is there any way to stop the Fullscreen Window from minimizing when I call the Message Box?

推荐答案

每当显示一个模式对话框(JOptionPane的,JFileChooser所等),在JFrame得到一个WINDOW_DEACTIVATED WindowEvent。当您的应用程序会显示为全屏根本无视窗口失:

Whenever a modal dialog is displayed (JOptionPane, JFileChooser, etc.), the JFrame gets a WINDOW_DEACTIVATED WindowEvent. Simply ignore the window deactivation when your app is displayed as fullscreen:

@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);        
}  

请务必正确设置模式对话框的父:

Be sure to set the parent of modal dialog correctly:

fileChooser.showOpenDialog(this);

在哪里这是您最顶端的JPanel,是JInternalFrame或JFrame的。

Where "this" is your top most JPanel, JInternalFrame, or JFrame.

这篇关于从最小化时停止JOptionPane.showMessageDialog全屏窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆