屏幕閃爍黑屏,然後單獨打開JFrame。全屏幕不工作
public Game() {
myDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
JFrame frame = new JFrame();
// frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);
frame.add(this);
myDevice.setFullScreenWindow(frame);
try {
} finally {
myDevice.setFullScreenWindow(null);
}
time = 0;
level = new LevelOne(this);
this.requestFocus();
try {
bgImg = ImageIO.read(new File("Space.png"));
} catch (IOException e) {
e.printStackTrace();
}
if (this.getBufferStrategy() == null)
this.createBufferStrategy(2);
bs = this.getBufferStrategy();
timer.schedule(new TimerTask() {
public void run() {
calc();
MobMover.calc();
render();
time++;
}
}, 0L, 40L);
}
我沒有看到這個問題...:'(
你有一個try'-block,它帶有一個單獨的'finally'子句,它將全屏設置爲null。請記住finally代碼塊總是會執行。甚至這個代碼塊的目的是什麼? – Jokab