EPUB-Checker icon indicating copy to clipboard operation
EPUB-Checker copied to clipboard

Full Screen Mode for Mac OS X

Open tofi86 opened this issue 9 years ago • 0 comments

seems to be provided with the Apple Java Extension Library.

See http://saipullabhotla.blogspot.de/2012/05/enabling-full-screen-mode-for-java.html for more details.

package com.myjavaworld.fullscreendemo;

import java.awt.Window;
import java.lang.reflect.Method;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class FullScreenDemo {
    public static void main(String[] args) {
        if (isMacOSX()) {
            System.setProperty(
                    "com.apple.mrj.application.apple.menu.about.name",
                    "Full Screen Demo");
        }
        JFrame frame = new JFrame("Full Screen Demo");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setSize(600, 400);
        if (isMacOSX()) {
            enableFullScreenMode(frame);
        }
        frame.setVisible(true);
    }

    public static void enableFullScreenMode(Window window) {
        String className = "com.apple.eawt.FullScreenUtilities";
        String methodName = "setWindowCanFullScreen";

        try {
            Class<?> clazz = Class.forName(className);
            Method method = clazz.getMethod(methodName, new Class<?>[] {
                    Window.class, boolean.class });
            method.invoke(null, window, true);
        } catch (Throwable t) {
            System.err.println("Full screen mode is not supported");
            t.printStackTrace();
        }
    }

    private static boolean isMacOSX() {
        return System.getProperty("os.name").indexOf("Mac OS X") >= 0;
    }
}

tofi86 avatar Aug 26 '14 20:08 tofi86