屏幕闪烁黑屏,然后单独打开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