全屏不起作用

Fullscreen doesnt work

黑屏然后单独打开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);
}

我没发现问题...:'(

此代码块将其设置为 null:

try {
    } finally {
        myDevice.setFullScreenWindow(null);
    }

所以删除它,它应该可以工作。