1 7 package org.jdesktop.swing.utils; 8 9 import java.lang.reflect.Method ; 10 import javax.swing.UIManager ; 11 import javax.swing.plaf.metal.MetalLookAndFeel ; 12 13 17 public final class UIManagerUtils { 18 21 private UIManagerUtils() { 22 } 23 24 30 public static void initDefault(String key, Object defaultObj) { 31 Object obj = UIManager.get(key); 32 if (obj == null) { 33 UIManager.put(key, defaultObj); 34 } 35 } 36 37 44 public static void initDefault(String key, String defaultMetalObjName, Object defaultObj) { 45 Object obj = UIManager.get(key); 46 if (obj == null) { 47 try { 48 Method m = ((MetalLookAndFeel )UIManager.getLookAndFeel()).getClass().getMethod(defaultMetalObjName, defaultObj.getClass()); 49 UIManager.put(key, m.invoke(UIManager.getLookAndFeel(), defaultMetalObjName)); 50 } catch (Exception e) { 51 UIManager.put(key, defaultObj); 52 } 53 } 54 } 55 } 56 | Popular Tags |