GraphicsDevice - cannot return from full screen mode

I am currently trying to create a full-screen window in Java running on Linux. The fact is that I can make full-screen JFrame, but if the frame is set without decoration, it cannot return to the original window again. If the windows are decorated, I can return to the original size.

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    ...
    f.setUndecorated(true);//If set Window can't return to original size
    gs.setFullScreenWindow(f);

    gs.setFullScreenWindow(null);//Doesn't work!

Any idea how to solve this?

+3
source share
2 answers
changeFrameFullScreenMode(Frame app){
  GraphicsDevice gd = GraphicsEnvironment
   .getLocalGraphicsEnvironment().getDefaultScreenDevice();
  if (gd.getFullScreenWindow() == null){
    app.dispose();
    app.setUndecorated(true);
    gd.setFullScreenWindow(app);
    app.setVisible(true);
  }else{ // back to windowed mode
    app.dispose();
    app.setUndecorated(false);
    gd.setFullScreenWindow(null);
    app.setVisible(true);
  }
}
+2
source

, . JFrame s, . , ( ), .

windowedFrame.setContentPane(fullScreenFrame.getContentPane());
windowedFrame.pack();
windowedFrame.setVisible(true);
fullScreenFrame.dispose();
0

All Articles