1 5 package net.sf.panoptes.swing.propeditors; 6 7 import javax.swing.JComponent ; 8 import javax.swing.JTextField ; 9 10 16 public class IntegerEditor extends JTextField implements PropertyEditor { 17 18 19 public IntegerEditor() { 20 super(new IntegerDocument(), "", 0); 21 } 22 23 public void setValue(Object value) { 24 if (!(value instanceof Integer )) throw new UnsupportedOperationException ("Only integers allowed"); 25 setText(value.toString()); 26 } 27 28 public Object getValue() { 29 return Integer.valueOf(getText()); 30 } 31 32 public JComponent getComponent() { 33 return this; 34 } 35 } 36 | Popular Tags |