1 19 20 package org.netbeans.util; 21 22 import javax.swing.LookAndFeel ; 23 import javax.swing.UIManager ; 24 25 30 31 public class Util { 32 33 34 private Util() { 35 } 36 37 44 public static void setDefaultLookAndFeel () { 45 String uiClassName; 46 if (isWindowsOS()) { 47 uiClassName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; } else if (isMacOSX()) { 49 uiClassName = "apple.laf.AquaLookAndFeel"; } else if (isLinuxOS() || isSunOS()) { 51 uiClassName = "javax.swing.plaf.metal.MetalLookAndFeel"; } else { 53 uiClassName = UIManager.getSystemLookAndFeelClassName(); 54 } 55 if (uiClassName.equals(UIManager.getLookAndFeel().getClass().getName())) { 56 return; 58 } 59 try { 60 UIManager.setLookAndFeel(uiClassName); 61 } catch (Exception ex) { 62 System.err.println("Cannot set L&F " + uiClassName); System.err.println("Exception:" + ex.getMessage()); ex.printStackTrace(); 65 } 66 } 67 68 private static boolean isWindowsOS() { 69 return System.getProperty("os.name").startsWith("Windows"); } 71 72 private static boolean isLinuxOS() { 73 return System.getProperty("os.name").startsWith("Lin"); } 75 76 private static boolean isSunOS() { 77 return System.getProperty("os.name").startsWith("Sun"); } 79 80 private static boolean isMacOSX() { 81 return System.getProperty("os.name").startsWith("Mac OS X"); } 83 84 } 85 86 | Popular Tags |