01: import java.beans.*;
02: 
03: /**
04:    A property editor for the draw mode of the CarBean.
05: */
06: public class DrawModeEditor extends PropertyEditorSupport
07: {
08:    public String[] getTags()
09:    {
10:       return new String[] { "Draw", "Fill" };
11:    }
12: 
13:    public String getAsText()
14:    {
15:       DrawMode value = (DrawMode) getValue();
16:       if (value == DrawMode.DRAW) return "Draw";
17:       if (value == DrawMode.FILL) return "Fill";
18:       return null;
19:    }
20: 
21:    public void setAsText(String s)
22:    {
23:       if (s.equals("Draw")) setValue(DrawMode.DRAW);
24:       else if (s.equals("Fill")) setValue(DrawMode.FILL);
25:       else throw new IllegalArgumentException();
26:    }
27: }