[英]Making JFrame fullscreen in Ubuntu/Unity
In Ubuntu (actually in unity), I can't make swing's JFrame's fullscreen. 在Ubuntu(实际上是统一的)中,我无法使swing的JFrame变为全屏显示。 I've tried lots of ways written in stackoverflow but noone of them worked for me. 我尝试了很多用stackoverflow编写的方法,但是没有一个对我有用。
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. 但是,ubuntu强迫我在上面显示Unity Launcher和菜单栏(时钟,wifi图标等)。
How can I run my Java programs in fullscreen mode? 如何以全屏模式运行Java程序? 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: 该程序如下所示:
您不能删除全局菜单或在其上方放置一个窗口,只需简单地将主题更改为另一个主题即可:lxde
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.