Java Full Screen setFullScreen(Window toplevel, boolean fullscreen)

Here you can find the source of setFullScreen(Window toplevel, boolean fullscreen)

Description

Makes a window full screen (method 1).

License

Open Source License

Declaration

public static boolean setFullScreen(Window toplevel, boolean fullscreen) 

Method Source Code

//package com.java2s;
/**//from   ww w  .j av  a  2 s  . com
 * Copyright (c) 2010-2014, Jean-Daniel Fekete, Pierre Dragicevic, and INRIA.
 * All rights reserved.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import java.awt.Window;

public class Main {
    /**
     * This is a temporary fix for the videos not showing in fullscreen timeline mode.
     */
    public static final boolean USE_TRUE_FULL_SCREEN = System.getProperty("os.name").toLowerCase()
            .indexOf("mac") > -1;

    /**
     * Makes a window full screen (method 1). Returns false if not supported.
     */
    public static boolean setFullScreen(Window toplevel, boolean fullscreen) {
        GraphicsDevice device;
        device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        if (USE_TRUE_FULL_SCREEN && device.isFullScreenSupported()) {
            boolean currentlyfullscreen = device.getFullScreenWindow() == toplevel;
            if (fullscreen != currentlyfullscreen)
                device.setFullScreenWindow(toplevel);
            return true;
        }
        return false;
    }
}

Related

  1. enableFullScreenMode(Window window)
  2. enableOSXFullscreen(Window window)
  3. makeFullscreen(Frame frame, boolean attemptExclusiveMode)