반응형

풀스크린 윈도우 (FullScreen Window) 만들기

import
 java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class FullScreen1 {
  GraphicsDevice device;

  public FullScreen1() {
    GraphicsEnvironment ge = GraphicsEnvironment
        .getLocalGraphicsEnvironment();
    device = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = device.getDefaultConfiguration();

    try {
      JFrame frame = new JFrame(gc);
      //프레임의 테두리를 없앤다.
      frame.setUndecorated(true);

      JButton button = new JButton("OK");
      button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          device.setFullScreenWindow(null);
          System.exit(0);
        }
      });

      frame.getContentPane().add(button);
      //frame을 스크린에 가득차도록 풀스크린 윈도우로 만듬
      device.setFullScreenWindow(frame);
      frame.setVisible(true);
    } catch (Exception ex) {
      device.setFullScreenWindow(null);
      System.exit(0);
    }
  }
  public static void main(String[] args) {
    new FullScreen1();
  }
}

+ Recent posts