1 32 33 package it.businesslogic.ireport.gui.sheet; 34 35 import java.util.*; 36 import javax.swing.*; 37 import it.businesslogic.ireport.util.*; 38 import it.businesslogic.ireport.gui.*; 39 40 public class DoubleSheetProperty extends SheetProperty { 41 42 private JNumberField editor = null; 43 44 public DoubleSheetProperty(String key, String name) { 45 super( key, name, SheetProperty.STRING, ""); 46 } 47 48 public JComponent getEditor() 49 { 50 if (editor != null) return editor; 51 editor = new JNumberField(); 52 try { 53 editor.setDecimals(-1); 54 editor.setGrouping(false); 55 editor.setInteger(false); 56 } catch (Exception ex) {} 57 editor.addActionListener( this ); 58 editor.setBorder(null); 59 return editor; 60 } 61 62 public Object getEditorValue(JComponent component) 63 { 64 return new Double (editor.getValue()); 65 } 66 67 public void setEditorValue(JComponent component, Object str) 68 { 69 70 try { 71 getEditor(); 73 if (str != null && str instanceof Double ) 74 { 75 editor.setValue(((Double )str).doubleValue() ); 76 } 77 else 78 { 79 editor.setValue( Double.parseDouble(""+str)); 80 } 81 } catch (Exception ex) {} 82 } 83 } 84 | Popular Tags |