1 23 24 package swingwtx.swing; 25 26 import swingwt.awt.*; 27 import swingwtx.swing.border.*; 28 import swingwtx.swing.event.*; 29 import swingwtx.swing.plaf.*; 30 31 import java.beans.PropertyChangeListener ; 32 import java.util.Locale ; 33 34 45 public class UIDefaults extends java.util.HashMap { 46 47 private SwingPropertyChangeSupport swingPropertyChangeSupport = new SwingPropertyChangeSupport(this); 48 49 private Object getKeyAsType(Object key, Class type) 50 { 51 Object value = get(key); 52 if (value.getClass().equals(type)) return value; 53 else return null; 54 } 55 56 private Object getKeyAsType(Object key, Locale locale, Class type) 57 { 58 return getKeyAsType(key, type); 60 } 61 62 public Font getFont(Object key) { return (Font) getKeyAsType(key, Font.class); } 63 public Font getFont(Object key, Locale locale) { return (Font) getKeyAsType(key, locale, Font.class); } 64 public Color getColor(Object key) { return (Color) getKeyAsType(key, Color.class); } 65 public Color getColor(Object key, Locale locale) { return (Color) getKeyAsType(key, locale, Color.class); } 66 public Icon getIcon(Object key) { return (Icon) getKeyAsType(key, Icon.class); } 67 public Icon getIcon(Object key, Locale locale) { return (Icon) getKeyAsType(key, locale, Icon.class); } 68 public Border getBorder(Object key) { return (Border) getKeyAsType(key, Border.class); } 69 public Border getBorder(Object key, Locale locale) { return (Border) getKeyAsType(key, locale, Border.class); } 70 public String getString(Object key) { return (String ) getKeyAsType(key, String .class); } 71 public String getString(Object key, Locale locale) { return (String ) getKeyAsType(key, locale, String .class); } 72 public Integer getInt(Object key) { return (Integer ) getKeyAsType(key, Integer .class); } 73 public Integer getInt(Object key, Locale locale) { return (Integer ) getKeyAsType(key, locale, Integer .class); } 74 public Boolean getBoolean(Object key) { return (Boolean ) getKeyAsType(key, Boolean .class); } 75 public Boolean getBoolean(Object key, Locale locale) { return (Boolean ) getKeyAsType(key, locale, Boolean .class); } 76 public Insets getInsets(Object key) { return (Insets) getKeyAsType(key, Insets.class); } 77 public Insets getInsets(Object key, Locale locale) { return (Insets) getKeyAsType(key, locale, Insets.class); } 78 public Dimension getDimension(Object key) { return (Dimension) getKeyAsType(key, Dimension.class); } 79 public Dimension getDimension(Object key, Locale locale) { return (Dimension) getKeyAsType(key, locale, Dimension.class); } 80 81 public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { swingPropertyChangeSupport.addPropertyChangeListener(listener); } 82 public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { swingPropertyChangeSupport.removePropertyChangeListener(listener); } 83 public synchronized PropertyChangeListener [] getPropertyChangeListeners() { return swingPropertyChangeSupport.getPropertyChangeListeners(); } 84 85 86 public Class getUIClass(String uiClassID, ClassLoader uiClassLoader) { return null; } 87 public Class getUIClass(String uiClassID) { return null; } 88 public ComponentUI getUI(JComponent target) { return null; } 89 public synchronized void addResourceBundle(String bundleName) {} 90 91 } | Popular Tags |