1 /*
2 * Copyright (c) 1997, 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
654 return systemLAF;
655 }
656 OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction());
657 if (osType == OSInfo.OSType.WINDOWS) {
658 return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
659 } else {
660 Toolkit toolkit = Toolkit.getDefaultToolkit();
661 if (toolkit instanceof SunToolkit) {
662 SunToolkit suntk = (SunToolkit)toolkit;
663 String desktop = suntk.getDesktop();
664 boolean gtkAvailable = suntk.isNativeGTKAvailable();
665 if ("gnome".equals(desktop) && gtkAvailable) {
666 return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
667 }
668 }
669 if (osType == OSInfo.OSType.MACOSX) {
670 if (toolkit.getClass() .getName()
671 .equals("sun.lwawt.macosx.LWCToolkit")) {
672 return "com.apple.laf.AquaLookAndFeel";
673 }
674 }
675 if (osType == OSInfo.OSType.SOLARIS) {
676 return "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
677 }
678 }
679 return getCrossPlatformLookAndFeelClassName();
680 }
681
682
683 /**
684 * Returns the name of the <code>LookAndFeel</code> class that implements
685 * the default cross platform look and feel -- the Java
686 * Look and Feel (JLF). This value can be overriden by setting the
687 * <code>swing.crossplatformlaf</code> system property.
688 *
689 * @return a string with the JLF implementation-class
690 * @see #setLookAndFeel
691 * @see #getSystemLookAndFeelClassName
692 */
693 public static String getCrossPlatformLookAndFeelClassName() {
694 String laf = AccessController.doPrivileged(
695 new GetPropertyAction("swing.crossplatformlaf"));
696 if (laf != null) {
|
1 /*
2 * Copyright (c) 1997, 2020, 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
654 return systemLAF;
655 }
656 OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction());
657 if (osType == OSInfo.OSType.WINDOWS) {
658 return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
659 } else {
660 Toolkit toolkit = Toolkit.getDefaultToolkit();
661 if (toolkit instanceof SunToolkit) {
662 SunToolkit suntk = (SunToolkit)toolkit;
663 String desktop = suntk.getDesktop();
664 boolean gtkAvailable = suntk.isNativeGTKAvailable();
665 if ("gnome".equals(desktop) && gtkAvailable) {
666 return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
667 }
668 }
669 if (osType == OSInfo.OSType.MACOSX) {
670 if (toolkit.getClass() .getName()
671 .equals("sun.lwawt.macosx.LWCToolkit")) {
672 return "com.apple.laf.AquaLookAndFeel";
673 }
674 }
675 }
676 return getCrossPlatformLookAndFeelClassName();
677 }
678
679
680 /**
681 * Returns the name of the <code>LookAndFeel</code> class that implements
682 * the default cross platform look and feel -- the Java
683 * Look and Feel (JLF). This value can be overriden by setting the
684 * <code>swing.crossplatformlaf</code> system property.
685 *
686 * @return a string with the JLF implementation-class
687 * @see #setLookAndFeel
688 * @see #getSystemLookAndFeelClassName
689 */
690 public static String getCrossPlatformLookAndFeelClassName() {
691 String laf = AccessController.doPrivileged(
692 new GetPropertyAction("swing.crossplatformlaf"));
693 if (laf != null) {
|