Enter full screen mode : Full Screen « 2D Graphics « Java Tutorial






import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Main {
  public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    Button btn = new Button("OK");
    btn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gs = ge.getDefaultScreenDevice();
        gs.setFullScreenWindow(null);
      }
    });
    Frame frame = new Frame(gs.getDefaultConfiguration());
    Window win = new Window(frame);
    win.add(btn, BorderLayout.CENTER);
    try {
      gs.setFullScreenWindow(win);
      win.validate();
    } finally {
      gs.setFullScreenWindow(null);
    }
  }
}








16.47.Full Screen
16.47.1.Full screen mode
16.47.2.Leave full-screen mode (Return to normal windowed mode)
16.47.3.Enter full screen mode
16.47.4.Determine if full-screen mode is supported directly