diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java b/Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java new file mode 100644 index 0000000..7c81745 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java @@ -0,0 +1,49 @@ +/* LightBulbBeanInfo.java */
+
+import java.awt.*;
+import java.beans.*;
+import java.lang.reflect.*;
+
+public class LightBulbBeanInfo
+extends SimpleBeanInfo
+{
+ public Image getIcon(int iconKind)
+ {
+ String imgname = "bulbico16.gif";
+ if (iconKind == BeanInfo.ICON_MONO_32x32 ||
+ iconKind == BeanInfo.ICON_COLOR_32x32) {
+ imgname = "bulbico32.gif";
+ }
+ return loadImage(imgname);
+ }
+
+ public PropertyDescriptor[] getPropertyDescriptors()
+ {
+ try {
+ PropertyDescriptor pd1 = new PropertyDescriptor(
+ "lightOn",
+ LightBulb.class
+ );
+ //pd1.setPropertyEditorClass(LightBulbLightOnEditor1.class);
+ PropertyDescriptor[] ret = {pd1};
+ return ret;
+ } catch (IntrospectionException e) {
+ System.err.println(e.toString());
+ return null;
+ }
+ }
+
+ public MethodDescriptor[] getMethodDescriptors()
+ {
+ MethodDescriptor[] ret = null;
+ try {
+ Class bulbclass = LightBulb.class;
+ Method meth1 = bulbclass.getMethod("toggleLight", null);
+ ret = new MethodDescriptor[1];
+ ret[0] = new MethodDescriptor(meth1);
+ } catch (NoSuchMethodException e) {
+ //ret bleibt null
+ }
+ return ret;
+ }
+}
\ No newline at end of file |
