01: import java.beans.*;
02:
03: /**
04: A property editor for the LineStyle type.
05: */
06: public class LineStyleEditor extends PropertyEditorSupport
07: {
08: public String[] getTags()
09: {
10: return new String[] { "Solid", "Dotted" };
11: }
12:
13: public String getAsText()
14: {
15: LineStyle mode = (LineStyle) getValue();
16: if (mode == LineStyle.SOLID) return "Solid";
17: if (mode == LineStyle.DOTTED) return "Dotted";
18: return null;
19: }
20:
21: public void setAsText(String s)
22: {
23: if (s.equals("Solid"))
24: setValue(LineStyle.SOLID);
25: else if (s.equals("Dotted"))
26: setValue(LineStyle.DOTTED);
27: else
28: throw new IllegalArgumentException();
29: }
30: }