2

I have an application that runs in fullscreen mode and has been working fine. Now I need to add a simple, undecorated dialog and I'm running into trouble. If I run the application maximized but not in fullscreen, the dialog displays and functions as expected. When I switch back to fullscreen, the dialog will not display.

The dialog extends JDialog and only contains a JSlider and a couple of buttons. It is undecorated and not modal. (I disabled modality for testing purposes -- it was a pain to force exit the app every time the dialog blocked input.) I'm entering full screen mode using setFullScreenWindow(), passing in the main JFrame for the app. It doesn't make a difference if I set that very JFrame as the owner of the JDialog or not. Nor does it seem to help if I call toFront() on the dialog.

The dialog seems to be active -- especially since it blocks input if I make it modal -- but just not showing or being hidden. So, is there any obvious trick to displaying a JDialog in fullscreen mode? Something I might be overlooking or omitting?

If there's no obvious solution, I can post some code later. Unfortunately, I don't have time right now.

Clayton
  • 1,967
  • 4
  • 18
  • 26
  • Uh oh. This doesn't bode well for me: "Windows cannot overlap the full-screen window. All other application windows will always appear beneath the full-screen window in the Z-order." From the API for GraphicsDevice: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/GraphicsDevice.html#setFullScreenWindow%28java.awt.Window%29 – Clayton Nov 13 '09 at 16:43

4 Answers4

5

JOptionPane.showInternalXXXDialog() methods render dialogs as JInternalFrames. Maybe you could consider using a JIternaFrame to simulate the dialog box.

Ustaman Sangat
  • 1,505
  • 1
  • 14
  • 26
2

And in fact, as M1EK alluded in his answer and I mentioned in a comment, Java applications in full screen mode will not allow other windows to show over them. The Javadoc API for GraphicsDevice reads:

Windows cannot overlap the full-screen window. All other application windows will always appear beneath the full-screen window in the Z-order.

In the end, I reconfigured my application so that it doesn't enter full screen mode until a bit later. This still gives me a fairly class presentation at the start and allows my JDialog to function as it should. The transition to full screen mode is quick and smooth, even in the "middle" of my app.

Clayton
  • 1,967
  • 4
  • 18
  • 26
1

Do you really want to be in full-screen mode for this app? That's more of a gaming feature - to get more direct access to the frame-buffer, I always thought. Have you read this tutorial:

http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html

Really seems to me not to be the best choice for a Swing app with child windows.

M1EK
  • 820
  • 5
  • 10
  • 1
    Good stuff to think about, but, yes, fullscreen mode is mandatory, as per client spec. This dialog will be the only child window, so it's nothing really complex. – Clayton Nov 13 '09 at 13:27
  • Currently mandatory for my client spec as well. If you are working in any kind of production environment having this to add to your toolbox is useful. – davidahines Feb 28 '11 at 18:37
1

Try to use this. Is not an exclusive full screen but it is close enough.

setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);
Stéphane Millien
  • 3,238
  • 22
  • 36
Alex
  • 847
  • 3
  • 15
  • 23