Path: blob/master/src/java.desktop/unix/classes/sun/awt/PlatformGraphicsInfo.java
41152 views
/*1* Copyright (c) 2019, 2021, 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 sun.awt;2627import java.awt.GraphicsEnvironment;28import java.awt.Toolkit;29import java.security.AccessController;30import java.security.PrivilegedAction;3132public class PlatformGraphicsInfo {3334public static GraphicsEnvironment createGE() {35return new X11GraphicsEnvironment();36}3738public static Toolkit createToolkit() {39return new sun.awt.X11.XToolkit();40}4142/**43* Called from java.awt.GraphicsEnvironment when44* to check if on this platform, the JDK should default to45* headless mode, in the case the application did specify46* a value for the java.awt.headless system property.47*/48@SuppressWarnings("removal")49public static boolean getDefaultHeadlessProperty() {50return51AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {5253final String display = System.getenv("DISPLAY");54return display == null || display.trim().isEmpty();55});56}5758/**59* Called from java.awt.GraphicsEnvironment when60* getDefaultHeadlessProperty() has returned true, and61* the application has called an API that requires headful.62*/63public static String getDefaultHeadlessMessage() {64return65"\nNo X11 DISPLAY variable was set,\n" +66"but this program performed an operation which requires it.";67}68}697071