1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.guilayer.swing.properties;
17
18 import java.lang.reflect.Method;
19
20 import org.xulux.api.gui.IProperty;
21 import org.xulux.api.gui.IWidget;
22 import org.xulux.api.gui.PropertyHandlerException;
23
24
25
26
27
28
29
30
31
32 public class IntrospectionProperty extends SwingProperty {
33
34
35
36
37 public IntrospectionProperty() {
38 super();
39
40 }
41
42
43
44
45 public boolean handleProperty(IWidget widget, IProperty property) {
46 Object nativeWidget = widget.getNativeWidget();
47 try {
48 String methodName = "set"+property.getName().substring(0,1).toUpperCase()+property.getName().substring(1).toLowerCase();
49 System.out.println("methodname : " + methodName);
50 Method method = nativeWidget.getClass().getMethod(methodName, new Class[] { String.class });
51 method.invoke(nativeWidget, new Object[] { property.getValue() });
52 return true;
53 } catch (Throwable e) {
54 throw new PropertyHandlerException("Dynamically setting property failed", e);
55 }
56 }
57 }