Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen feature for Java Apps on OSX Lion

Tags:

How can I (natively) implement the fullscreen feature of OSX Lion in a Java application?

The current answers given incorporate a good method for achieving a sort-of-fullscreen feature. I've read that Eclipse may be able to use the "native" fullscreen feature of Lion. That's what I'm asking about.

like image 439
gamma Avatar asked Jul 29 '11 13:07

gamma


People also ask

How do I maximize a window in Mac without full screen?

When the cursor icon changes to a diagonal bi-directional arrow, press and hold the Option key and double click. This would zoom the window to occupy the entire screen without it entering into full-screen mode.

How do I keep apps from full screen on my Mac?

To stop using the app full screen, move the pointer to the green button again, then choose Exit Full Screen from the menu that appears or click the button .


2 Answers

I found this on Apple's Java release notes:

Mac OS X 10.7 Lion Fullscreen Support

Java applications on Lion can now opt into the Fullscreen window feature per-window. Developers can use the com.apple.eawt.FullScreenUtilities class to mark windows as able to be full screened, and the com.apple.eawt.Application.requestToggleFullScreen(Window) method to programmatically request the window enter and exit full screen mode. This API does nothing on Mac OS X 10.6 Snow Leopard.

More explicitly, try calling this early on from the constructor of your JFrames...

/**
 * @param window
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public static void enableOSXFullscreen(Window window) {
    Preconditions.checkNotNull(window);
    try {
        Class util = Class.forName("com.apple.eawt.FullScreenUtilities");
        Class params[] = new Class[]{Window.class, Boolean.TYPE};
        Method method = util.getMethod("setWindowCanFullScreen", params);
        method.invoke(util, window, true);
    } catch (ClassNotFoundException e1) {
    } catch (Exception e) {
        log.log(Level.WARNING, "OS X Fullscreen FAIL", e);
    }
}
like image 111
Dyorgio Avatar answered Sep 27 '22 15:09

Dyorgio


I don't know about natively, but Java does support fullscreen applications without needing native code:

http://saipullabhotla.blogspot.com/2012/05/enabling-full-screen-mode-for-java.html

The question is has Apple implemented that with Lion in their JDK.

like image 29
chubbsondubs Avatar answered Sep 27 '22 17:09

chubbsondubs