KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > panoptes > swing > propeditors > IntegerEditor


1 /*
2  * Created on Sep 6, 2003
3  *
4  */

5 package net.sf.panoptes.swing.propeditors;
6
7 import javax.swing.JComponent JavaDoc;
8 import javax.swing.JTextField JavaDoc;
9
10 /**
11  *
12  *
13  * @author Dag Liodden
14  * @version 0.1
15  */

16 public class IntegerEditor extends JTextField JavaDoc implements PropertyEditor {
17
18
19     public IntegerEditor() {
20         super(new IntegerDocument(), "", 0);
21     }
22     
23     public void setValue(Object JavaDoc value) {
24         if (!(value instanceof Integer JavaDoc)) throw new UnsupportedOperationException JavaDoc("Only integers allowed");
25         setText(value.toString());
26     }
27     
28     public Object JavaDoc getValue() {
29         return Integer.valueOf(getText());
30     }
31
32     public JComponent JavaDoc getComponent() {
33         return this;
34     }
35 }
36
Popular Tags