1 7 package org.ejtools.adwt.editor; 8 9 10 17 public class NumberEditor extends GenericEditor 18 { 19 20 protected Class clazz = Number .class; 21 22 23 24 public NumberEditor() 25 { 26 this.value = new Integer (0); 27 } 28 29 30 35 public String getAsText() 36 { 37 return value.toString(); 38 } 39 40 41 46 public void setAsText(String s) 47 { 48 if (this.clazz.equals(Integer .class)) 49 { 50 this.value = new Integer (s); 51 } 52 else if (this.clazz.equals(Float .class)) 53 { 54 this.value = new Float (s); 55 } 56 else if (this.clazz.equals(Double .class)) 57 { 58 this.value = new Double (s); 59 } 60 else if (this.clazz.equals(Byte .class)) 61 { 62 this.value = new Byte (s); 63 } 64 else if (this.clazz.equals(Short .class)) 65 { 66 this.value = new Short (s); 67 } 68 else if (this.clazz.equals(Long .class)) 69 { 70 this.value = new Long (s); 71 } 72 this.firePropertyChange(); 73 } 74 75 76 81 public void setValue(Object object) 82 { 83 super.setValue(object); 84 this.clazz = object.getClass(); 85 } 86 } 87 88 | Popular Tags |