2017-08-16 63 views
1

我一直在使用这个代码在屏幕上手动设置我的显示器的像素尺寸:如何JFrame的设置全屏

public static void main(String[] args) { 
     Game game = new Game("ColoursAndShapes", 1920, 970); 
     game.start(); 
} 

我想找到一种方法来设置的JFrame到全屏任意监视器上,但考虑到我的“游戏”类包含其他方法和变量,我无法从此启动程序代码中删除它。

+2

你读这https://stackoverflow.com/questions/11570356/jframe-in-full-screen-java –

回答

1
JFrame JFrame = new JFrame(); 
frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setUndecorated(true); 
frame.setVisible(true); 
+0

虽然这个代码片断可以解决的问题,[包括说明](//元.stackexchange.com/questions/114762/explain-completely-code-based-answers)确实有助于提高帖子的质量。请记住,您将来会为读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性注释来挤占代码,这会降低代码和解释的可读性! – rene