Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full Screen Mode Isn't Full Screen [duplicate]

So I'm using Ubuntu and when I want to enter fullscreen mode in Java, a normal window appears with max screen size, instead of a fullscreen window without title bar etc. I admit, I'm not even sure what the fullscreen mode should look like in Java, because I have not tried it on any other OS. But I assume it should be a screen without title bar. Anyone else who has this problem?

This is the code I use. ; pretty straight forward.

public static void main(String[] args) {
    GraphicsEnvironment env = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsDevice vc = env.getDefaultScreenDevice();
    JFrame window = new JFrame();
    window.setUndecorated(false);
    window.setResizable(false);
    vc.setFullScreenWindow(window);
}
like image 397
Jon Avatar asked Sep 20 '12 20:09

Jon


People also ask

How do I duplicate a full screen?

Close all open programs. Right-click an empty area on your desktop, and click Display Settings. Click the Multiple Displays drop-down list, and select Duplicate these displays or Extend these displays or Show only on 1 or Show only on 2.

Why can I duplicate my screen but not extend?

Make sure that your settings are on Extend these displays: In the Multiple displays sections of Displays on Windows, make sure the Extend these displays option is chosen. It's a good idea to check all your Display settings to make sure they are set up for multiple monitors: Sometimes a Windows update can reset them.

Why is my full screen not full?

Step 1: On the Windows Desktop, right-click the blank space and choose Display settings. Alternatively, you can click Start > Settings > System to enter the Display interface. Step 2: Under the Scale and layout section, ensure the scaling of Change the size of text, apps, and other items is set to 100%.


3 Answers

On Ubuntu (probably other Linux distros as well) it doesn't work. Full screen mode in Java doesn't cover the full screen. It leaves the toolbars out. Always, whatever you do.

I tried the two examples above and the examples from the official FSEM tutorial and some application I know are using Java/Swing and Full screen mode (FreeCol and TripleX) and noone was able to cover the task/toolbar areas of the screen.

My configuration is Ubuntu 12.10 with either OpenJDK or SUN-JRE 1.7.0_09 and either Unity or Gnome. Interestingly the java call to isFullScreenSupported() returns true. So, while the Java JRE says it supports full screen exclusive, it doesn't.

Some possible explanations might be given in another question.

like image 90
Trilarion Avatar answered Sep 23 '22 11:09

Trilarion


On win7, with this code (I set the undecorated flag to true as suggested by @Gilberto and added a RED panel) it seems to work OK. If it does not work on Ubuntu, then it may mean that FullScreen mode is unsupported:

import java.awt.Color;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main {
    public static void main(String[] args) {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice vc = env.getDefaultScreenDevice();
        JFrame window = new JFrame();
        JPanel comp = new JPanel();
        comp.setBackground(Color.RED);
        window.add(comp);
        window.setUndecorated(true);
        window.setResizable(false);
        vc.setFullScreenWindow(window);
    }
}
like image 30
Guillaume Polet Avatar answered Sep 19 '22 11:09

Guillaume Polet


This thread is very old but still comes in ACTUAL search results but with wrong answers. So i'll post actual the real solution.

Swing full screen will be set with the setExtendedState() function, not with the setFullScreenWindow() function!

JFrame myFrame = new JFrame();
....
myFrame.setExtendedState(MAXIMIZED_BOTH);

Then u'll have a decorated full screen window, with all buttons and a correct toolbar optic and it works fine with Ubuntu and any other OS.

like image 36
Marantis Avatar answered Sep 21 '22 11:09

Marantis