Java Swing Tutorial - Java GraphicsDevice .setFullScreenWindow (Window w)


GraphicsDevice.setFullScreenWindow(Window w) has the following syntax.

public void setFullScreenWindow(Window w)


In the following code shows how to use GraphicsDevice.setFullScreenWindow(Window w) method.

//from   w ww .j a v a2 s. co  m

import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;

public class Main extends Window {

  private BufferedImage pic;

  public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice screen = ge.getDefaultScreenDevice();

    if (!screen.isFullScreenSupported()) {
      System.out.println("Full screen mode not supported");

    try {
      BufferedImage loadedpic = File("your.jpg"));
      screen.setFullScreenWindow(new Main (loadedpic));
    } catch (Exception e) {

  public Main (BufferedImage pic) {
    super(new Frame());

    this.pic = pic;

    addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {

  public void paint(Graphics g) {
    g.drawImage(pic, 0, 0, getWidth(), getHeight(), this);

The code above generates the following result.