1 17 18 package swingwtx.swing.plaf.metal; 19 20 import swingwtx.swing.plaf.ComponentUI; 21 import swingwtx.swing.JComponent; 22 23 import java.util.HashMap ; 24 25 37 public class GenericComponentUI extends ComponentUI 38 { 39 private static HashMap defaultComponentUIs = new HashMap (); 40 41 private Class componentClass; 42 43 public static ComponentUI createUI(JComponent component) 44 { 45 if (component == null) 46 throw new NullPointerException (); 47 48 return createUI(component.getClass()); 49 } 50 51 public static ComponentUI createUI(Class componentClass) 52 { 53 if (componentClass == null) 54 throw new NullPointerException (); 55 56 GenericComponentUI componentUI = null; 57 if (defaultComponentUIs.containsKey(componentClass)) 58 { 59 componentUI = (GenericComponentUI) defaultComponentUIs.get(componentClass); 60 } 61 else 62 { 63 componentUI = new GenericComponentUI(componentClass); 64 defaultComponentUIs.put(componentClass, componentUI); 65 } 66 return componentUI; 67 } 68 69 public GenericComponentUI(Class componentClass) 70 { 71 super(); 72 this.componentClass = componentClass; 73 } 74 } 75 | Popular Tags |