sedran
sedran

Reputation: 3566

Making JFrame fullscreen in Ubuntu/Unity

In Ubuntu (actually in unity), I can't make swing's JFrame's fullscreen. I've tried lots of ways written in stackoverflow but noone of them worked for me.

I'm trying to develop a game and I need to see nothing but my game on my screen. However, ubuntu forces me to display Unity Launcher and the menubar(Clock, wifi icon, etc..) above.

How can I run my Java programs in fullscreen mode? Here's my code:

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

import javax.swing.JFrame;

public class Starter extends JFrame {
    private static final long serialVersionUID = -2656706278597877008L;

    public static void main(String[] args) {
        new Starter();
    }

    public Starter() {
        super(UIConstants.FRAME_TITLE);
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setUndecorated(true);
        makeFullScreen();
        setVisible(true);
    }

    private void makeFullScreen() {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice device = env.getDefaultScreenDevice();
        device.setFullScreenWindow(this);
    }
}

And this program is seen as follows: the program output

Upvotes: 2

Views: 759

Answers (1)

user2765127
user2765127

Reputation: 26

you can't remove the global menu or place a window on top of it, simply, change the theme to another like: lxde

Upvotes: 1

Related Questions