Java – stop the full screen window to minimize joptionpane showMessageDialog?
•
Java
code
private MainApp() /* Extends JFrame */{
DisplayMode displayMode = new DisplayMode(800,600,16,75);
ScreenManager.setFullScreenWindow(displayMode,this);
}
problem
Whenever I call:
JOptionPane.showMessageDialog(MainApp.getInstance(),"Test Message @R_29_2419@");
The window was minimized for some reason, and then I had to reactivate it When the window is reactivated, a message box appears
problem
Is there any way to prevent the full screen window from being minimized when I call the message box?
Solution
Whenever the Mode dialog box (joptionpane, Jfilechooser, etc.) is displayed, JFrame will get a window_ DEACTIVATED WindowEvent. When your application is displayed in full screen, just ignore the window deactivation:
@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 the modal dialog box correctly:
fileChooser.showOpenDialog(this);
"This" is your top JPanel, jinternalframe or JFrame
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
