The Code
private MainApp() /* Extends JFrame */{
DisplayMode displayMode = new DisplayMode(800, 600, 16, 75);
ScreenManager.setFullScreenWindow(displayMode, this);
}
The Problem
Whenever I call:
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.
The Question
Is there any way to stop the Fullscreen Window from minimizing when I call the Message Box?
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);
Where "this" is your top most JPanel, JInternalFrame, or JFrame.