1 /*
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
189 public boolean isFullScreenSupported() {
190 return isFSExclusiveModeAllowed();
191 }
192
193 private static boolean isFSExclusiveModeAllowed() {
194 SecurityManager security = System.getSecurityManager();
195 if (security != null) {
196 if (fullScreenExclusivePermission == null) {
197 fullScreenExclusivePermission =
198 new AWTPermission("fullScreenExclusive");
199 }
200 try {
201 security.checkPermission(fullScreenExclusivePermission);
202 } catch (SecurityException e) {
203 return false;
204 }
205 }
206 return true;
207 }
208
209 @SuppressWarnings("deprecation")
210 private static void enterFullScreenExclusive(Window w) {
211 FullScreenCapable peer = (FullScreenCapable)w.getPeer();
212 if (peer != null) {
213 peer.enterFullScreenMode();
214 }
215 }
216
217 @SuppressWarnings("deprecation")
218 private static void exitFullScreenExclusive(Window w) {
219 FullScreenCapable peer = (FullScreenCapable)w.getPeer();
220 if (peer != null) {
221 peer.exitFullScreenMode();
222 }
223 }
224
225 @Override
226 public boolean isDisplayChangeSupported() {
227 return true;
228 }
229
230 @Override
231 public void setDisplayMode(final DisplayMode dm) {
232 if (dm == null) {
233 throw new IllegalArgumentException("Invalid display mode");
234 }
235 if (!Objects.equals(dm, getDisplayMode())) {
236 nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(),
237 dm.getBitDepth(), dm.getRefreshRate());
238 if (isFullScreenSupported() && getFullScreenWindow() != null) {
239 getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight());
|
1 /*
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
189 public boolean isFullScreenSupported() {
190 return isFSExclusiveModeAllowed();
191 }
192
193 private static boolean isFSExclusiveModeAllowed() {
194 SecurityManager security = System.getSecurityManager();
195 if (security != null) {
196 if (fullScreenExclusivePermission == null) {
197 fullScreenExclusivePermission =
198 new AWTPermission("fullScreenExclusive");
199 }
200 try {
201 security.checkPermission(fullScreenExclusivePermission);
202 } catch (SecurityException e) {
203 return false;
204 }
205 }
206 return true;
207 }
208
209 private static void enterFullScreenExclusive(Window w) {
210 FullScreenCapable peer = AWTAccessor.getComponentAccessor().getPeer(w);
211 if (peer != null) {
212 peer.enterFullScreenMode();
213 }
214 }
215
216 private static void exitFullScreenExclusive(Window w) {
217 FullScreenCapable peer = AWTAccessor.getComponentAccessor().getPeer(w);
218 if (peer != null) {
219 peer.exitFullScreenMode();
220 }
221 }
222
223 @Override
224 public boolean isDisplayChangeSupported() {
225 return true;
226 }
227
228 @Override
229 public void setDisplayMode(final DisplayMode dm) {
230 if (dm == null) {
231 throw new IllegalArgumentException("Invalid display mode");
232 }
233 if (!Objects.equals(dm, getDisplayMode())) {
234 nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(),
235 dm.getBitDepth(), dm.getRefreshRate());
236 if (isFullScreenSupported() && getFullScreenWindow() != null) {
237 getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight());
|