简体   繁体   中英

Fullscreen doesnt work

The screen flashs black up and then the JFrame is opened alone.

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);
}

I don't see the problem... :'(

This block of code will set it to null :

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

So remove that and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM