KickJava   Java API By Example, From Geeks To Geeks.

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


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 StringEditor extends JTextField JavaDoc implements PropertyEditor {
17         
18     public StringEditor() {
19         super();
20     }
21     
22     public void setValue(Object JavaDoc value) {
23         if (!(value instanceof String JavaDoc)) throw new UnsupportedOperationException JavaDoc("Only Strings allowed");
24         setText(value.toString());
25     }
26     
27     public Object JavaDoc getValue() {
28         return getText();
29     }
30     
31     public JComponent JavaDoc getComponent() {
32         return this;
33     }
34 }
35
Popular Tags