Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/macosx/classes/com/apple/eawt/FullScreenUtilities.java
38831 views
/*1* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.apple.eawt;2627import java.awt.*;2829import javax.swing.RootPaneContainer;3031import sun.lwawt.macosx.*;3233import com.apple.eawt.event.GestureUtilities;3435/**36* Utility class perform animated full screen actions to top-level {@link Window}s.37*38* This class manages the relationship between {@link Windows}s and the {@link FullScreenListener}s39* attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities}40* class which adds additional functionality to AWT Windows, without adding new API to the41* {@link java.awt.Window} class.42*43* Full screen operations can only be performed on top-level {@link Window}s that are also {@link RootPaneContainer}s.44*45* @see FullScreenAdapter46* @see GestureUtilities47* @see com.sun.awt.AWTUtilities48*49* @since Java for Mac OS X 10.7 Update 150*/51public final class FullScreenUtilities {52FullScreenUtilities() {53// package private54}5556/**57* Marks a {@link Window} as able to animate into or out of full screen mode.58*59* Only top-level {@link Window}s which are {@link RootPaneContainer}s are able to be animated into and out of full screen mode.60* The {@link Window} must be marked as full screen-able before the native peer is created with {@link Component#addNotify()}.61*62* @param window63* @param canFullScreen64* @throws IllegalArgumentException if window is not a {@link RootPaneContainer}65*/66public static void setWindowCanFullScreen(final Window window, final boolean canFullScreen) {67if (!(window instanceof RootPaneContainer)) throw new IllegalArgumentException("Can't mark a non-RootPaneContainer as full screen-able");68final RootPaneContainer rpc = (RootPaneContainer)window;69rpc.getRootPane().putClientProperty(CPlatformWindow.WINDOW_FULLSCREENABLE, Boolean.valueOf(canFullScreen));70}7172/**73* Attaches a {@link FullScreenListener} to the specified top-level {@link Window}.74* @param window to attach the {@link FullScreenListener} to75* @param listener to be notified when a full screen event occurs76* @throws IllegalArgumentException if window is not a {@link RootPaneContainer}77*/78public static void addFullScreenListenerTo(final Window window, final FullScreenListener listener) {79if (!(window instanceof RootPaneContainer)) throw new IllegalArgumentException("Can't attach FullScreenListener to a non-RootPaneContainer");80if (listener == null) throw new NullPointerException();81FullScreenHandler.addFullScreenListenerTo((RootPaneContainer)window, listener);82}8384/**85* Removes a {@link FullScreenListener} from the specified top-level {@link Window}.86* @param window to remove the {@link FullScreenListener} from87* @param listener to be removed88* @throws IllegalArgumentException if window is not a {@link RootPaneContainer}89*/90public static void removeFullScreenListenerFrom(final Window window, final FullScreenListener listener) {91if (!(window instanceof RootPaneContainer)) throw new IllegalArgumentException("Can't remove FullScreenListener from non-RootPaneContainer");92if (listener == null) throw new NullPointerException();93FullScreenHandler.removeFullScreenListenerFrom((RootPaneContainer)window, listener);94}95}969798