1 /* 2 * Copyright (c) 2019, 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 23 * questions. 24 */ 25 26 package org.netbeans.jemmy.util; 27 28 import javax.swing.UIManager; 29 30 /** 31 * Class to provide look and feel related utility APIs 32 */ 33 public class LookAndFeel { 34 35 /** 36 * Checking whether the current look and feel is Metal L&F 37 * 38 * @return returns true if current look and feel is Metal L&F, 39 * otherwise false 40 */ isMetal()41 public static boolean isMetal() { 42 return isLookAndFeel("Metal"); 43 } 44 45 /** 46 * Checking whether the current look and feel is Nimbus L&F 47 * 48 * @return returns true if current look and feel is Nimbus L&F, 49 * otherwise false 50 */ isNimbus()51 public static boolean isNimbus() { 52 return isLookAndFeel("Nimbus"); 53 } 54 55 /** 56 * Checking whether the current look and feel is Motif L&F 57 * 58 * @return returns true if current look and feel is Motif L&F, 59 * otherwise false 60 */ isMotif()61 public static boolean isMotif() { 62 return isLookAndFeel("Motif"); 63 } 64 65 /** 66 * Checking whether the current look and feel is GTK L&F 67 * 68 * @return returns true if current look and feel is GTK L&F, 69 * otherwise false 70 */ isGTK()71 public static boolean isGTK() { 72 return isLookAndFeel("GTK"); 73 } 74 75 /** 76 * Checking whether the current look and feel is Aqua L&F 77 * 78 * @return returns true if current look and feel is Aqua L&F, 79 * otherwise false 80 */ isAqua()81 public static boolean isAqua() { 82 return isLookAndFeel("Aqua"); 83 } 84 85 /** 86 * Checking whether the current look and feel is Windows L&F 87 * 88 * @return returns true if current look and feel is Windows L&F, 89 * otherwise false 90 */ isWindows()91 public static boolean isWindows() { 92 return UIManager.getLookAndFeel().getClass(). 93 getSimpleName().equals("WindowsLookAndFeel"); 94 } 95 96 /** 97 * Checking whether the current look and feel is WindowsClassic L&F 98 * 99 * @return returns true if current look and feel is WindowsClassic L&F, 100 * otherwise false 101 */ isWindowsClassic()102 public static boolean isWindowsClassic() { 103 return UIManager.getLookAndFeel().getClass(). 104 getSimpleName().equals("WindowsClassicLookAndFeel"); 105 } 106 isLookAndFeel(String id)107 private static boolean isLookAndFeel(String id) { 108 return UIManager.getLookAndFeel().getID().equals(id); 109 } 110 } 111