1 7 8 package java.beans; 9 10 import java.beans.*; 11 12 17 18 public class PropertyEditorSupport implements PropertyEditor { 19 20 25 public PropertyEditorSupport() { 26 setSource(this); 27 } 28 29 35 public PropertyEditorSupport(Object source) { 36 if (source == null) { 37 throw new NullPointerException (); 38 } 39 setSource(source); 40 } 41 42 51 public Object getSource() { 52 return source; 53 } 54 55 65 public void setSource(Object source) { 66 this.source = source; 67 } 68 69 77 public void setValue(Object value) { 78 this.value = value; 79 firePropertyChange(); 80 } 81 82 87 public Object getValue() { 88 return value; 89 } 90 91 93 98 99 public boolean isPaintable() { 100 return false; 101 } 102 103 114 public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) { 115 } 116 117 119 130 public String getJavaInitializationString() { 131 return "???"; 132 } 133 134 136 146 public String getAsText() { 147 if (value instanceof String ) { 148 return (String )value; 149 } 150 return ("" + value); 151 } 152 153 161 public void setAsText(String text) throws java.lang.IllegalArgumentException { 162 if (value instanceof String ) { 163 setValue(text); 164 return; 165 } 166 throw new java.lang.IllegalArgumentException (text); 167 } 168 169 171 182 public String [] getTags() { 183 return null; 184 } 185 186 188 202 203 public java.awt.Component getCustomEditor() { 204 return null; 205 } 206 207 212 public boolean supportsCustomEditor() { 213 return false; 214 } 215 216 218 225 public synchronized void addPropertyChangeListener( 226 PropertyChangeListener listener) { 227 if (listeners == null) { 228 listeners = new java.util.Vector (); 229 } 230 listeners.addElement(listener); 231 } 232 233 238 public synchronized void removePropertyChangeListener( 239 PropertyChangeListener listener) { 240 if (listeners == null) { 241 return; 242 } 243 listeners.removeElement(listener); 244 } 245 246 249 public void firePropertyChange() { 250 java.util.Vector targets; 251 synchronized (this) { 252 if (listeners == null) { 253 return; 254 } 255 targets = (java.util.Vector ) listeners.clone(); 256 } 257 PropertyChangeEvent evt = new PropertyChangeEvent (source, null, null, null); 259 260 for (int i = 0; i < targets.size(); i++) { 261 PropertyChangeListener target = (PropertyChangeListener )targets.elementAt(i); 262 target.propertyChange(evt); 263 } 264 } 265 266 268 private Object value; 269 private Object source; 270 private java.util.Vector listeners; 271 } 272 | Popular Tags |