From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/LightBulbBeanInfo.java | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/LightBulbBeanInfo.java') 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 -- cgit v1.2.3