1 18 19 package org.objectweb.jac.aspects.gui.swing; 20 21 import java.text.ParsePosition ; 22 import org.objectweb.jac.aspects.gui.FloatFormat; 23 import org.objectweb.jac.aspects.gui.NumberFormat; 24 import org.objectweb.jac.core.rtti.FieldItem; 25 import org.objectweb.jac.util.WrappedThrowableException; 26 27 33 public class FloatEditor extends FormatEditor 34 { 35 public FloatEditor(Object substance, FieldItem field) { 36 super(substance,field); 37 } 38 39 protected void initFormat(FieldItem field) { 40 format = new FloatFormat(field); 41 } 42 43 public Object parse(String s) { 44 ParsePosition pos = new ParsePosition (0); 45 Class cl = type.getActualClass(); 46 if (cl==float.class || cl==Float .class) { 47 return ((NumberFormat)format).parseFloat(s,pos); 48 } else if (cl==double.class || cl==Double .class) { 49 return ((NumberFormat)format).parseDouble(s,pos); 50 } else { 51 throw new RuntimeException ("FloatEditor: Unhandled type "+type.getName()); 52 } 53 } 54 } 55 | Popular Tags |