2016-08-16 228 views
0

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

我没有看到这个问题...:'(

+1

你有一个try'-block,它带有一个单独的'finally'子句,它将全屏设置为null。请记住finally代码块总是会执行。甚至这个代码块的目的是什么? – Jokab

回答

0

的代码块将其设置为null

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

所以删除,它应该工作

+0

谢谢你是stup id xD 但是现在我有一个黑色条,其中任务栏通常为 – Crudellor

+0

尝试添加以下任一项或两项:frame.setExtendedState(Frame.MAXIMIZED_BOTH)/ frame.setUndecorated(true) – notyou