diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/LightBulbLightOnEditor1.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/LightBulbLightOnEditor1.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/LightBulbLightOnEditor1.java b/Master/Reference Architectures and Patterns/hjp5/examples/LightBulbLightOnEditor1.java new file mode 100644 index 0000000..da8274f --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/LightBulbLightOnEditor1.java @@ -0,0 +1,38 @@ +/* LightBulbLightOnEditor1.java */
+
+import java.awt.*;
+import java.beans.*;
+
+public class LightBulbLightOnEditor1
+extends PropertyEditorSupport
+{
+ boolean currentvalue;
+
+ public void setValue(Object value)
+ {
+ currentvalue = ((Boolean)value).booleanValue();
+ }
+
+ public Object getValue()
+ {
+ return new Boolean(currentvalue);
+ }
+
+ public String getAsText()
+ {
+ return "" + (currentvalue ? "an" : "aus");
+ }
+
+ public void setAsText(String text)
+ throws java.lang.IllegalArgumentException
+ {
+ if (text.equalsIgnoreCase("an")) {
+ currentvalue = true;
+ } else if (text.equalsIgnoreCase("aus")) {
+ currentvalue = false;
+ } else {
+ throw new IllegalArgumentException(text);
+ }
+ firePropertyChange();
+ }
+}
\ No newline at end of file |
