< prev index next >

src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java

Print this page




1077          * Name of the class to create.
1078          */
1079         private String className;
1080         private String methodName;
1081 
1082         GTKLazyValue(String name) {
1083             this(name, null);
1084         }
1085 
1086         GTKLazyValue(String name, String methodName) {
1087             this.className = name;
1088             this.methodName = methodName;
1089         }
1090 
1091         public Object createValue(UIDefaults table) {
1092             try {
1093                 Class<?> c = Class.forName(className, true,Thread.currentThread().
1094                                            getContextClassLoader());
1095 
1096                 if (methodName == null) {
1097                     return c.newInstance();


1098                 }
1099                 Method m = c.getMethod(methodName, (Class<?>[])null);
1100 
1101                 return m.invoke(c, (Object[])null);
1102             } catch (ClassNotFoundException cnfe) {
1103             } catch (IllegalAccessException iae) {
1104             } catch (InvocationTargetException ite) {
1105             } catch (NoSuchMethodException nsme) {
1106             } catch (InstantiationException ie) {
1107             }
1108             return null;
1109         }
1110     }
1111 
1112     static {
1113         CLASS_SPECIFIC_MAP = new HashMap<String,String>();
1114         CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width");
1115         CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border");
1116         CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size");
1117         CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size");




1077          * Name of the class to create.
1078          */
1079         private String className;
1080         private String methodName;
1081 
1082         GTKLazyValue(String name) {
1083             this(name, null);
1084         }
1085 
1086         GTKLazyValue(String name, String methodName) {
1087             this.className = name;
1088             this.methodName = methodName;
1089         }
1090 
1091         public Object createValue(UIDefaults table) {
1092             try {
1093                 Class<?> c = Class.forName(className, true,Thread.currentThread().
1094                                            getContextClassLoader());
1095 
1096                 if (methodName == null) {
1097                     @SuppressWarnings("deprecation")
1098                     Object result = c.newInstance();
1099                     return result;
1100                 }
1101                 Method m = c.getMethod(methodName, (Class<?>[])null);
1102 
1103                 return m.invoke(c, (Object[])null);
1104             } catch (ClassNotFoundException cnfe) {
1105             } catch (IllegalAccessException iae) {
1106             } catch (InvocationTargetException ite) {
1107             } catch (NoSuchMethodException nsme) {
1108             } catch (InstantiationException ie) {
1109             }
1110             return null;
1111         }
1112     }
1113 
1114     static {
1115         CLASS_SPECIFIC_MAP = new HashMap<String,String>();
1116         CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width");
1117         CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border");
1118         CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size");
1119         CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size");


< prev index next >