Question

I'd like my application to have a full-screen mode. What is the easiest way to do this, do I need a third party library for this or is there something in the JDK that already offers this?

Was it helpful?

Solution

Try the Full-Screen Exclusive Mode API. It was introduced in the JDK in release 1.4. Some of the features include:

  • Full-Screen Exclusive Mode - allows you to suspend the windowing system so that drawing can be done directly to the screen.
  • Display Mode - composed of the size (width and height of the monitor, in pixels), bit depth (number of bits per pixel), and refresh rate (how frequently the monitor updates itself).
  • Passive vs. Active Rendering - painting while on the main event loop using the paint method is passive, whereas rendering in your own thread is active.
  • Double Buffering and Page Flipping - Smoother drawing means better perceived performance and a much better user experience.
  • BufferStrategy and BufferCapabilities - classes that allow you to draw to surfaces and components without having to know the number of buffers used or the technique used to display them, and help you determine the capabilities of your graphics device.

There are several full-screen exclusive mode examples in the linked tutorial.

OTHER TIPS

JFrame setUndecorated(true) method

I've done this using JOGL when having a full screen OpenGL user interface for a game. It's quite easy. I believe that the capability was added to Java with version 5 as well, but it's so long ago that I've forgotten how to do it (edit: see answer above for how).

Use this code:

JFrame frame = new JFrame();
// set properties
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
frame.setUndecorated(true);
frame.setVisible(true);

Make sure setUndecorated() comes before setVisible() or it won't work.

It really depends on what you're using to display your interface, i.e. AWT/Spring or OpenGL etc.

Java has a full screen exclusive mode API - see this tutorial from Sun.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top