1114 * Name of the class to create. 1115 */ 1116 private String className; 1117 private String methodName; 1118 1119 GTKLazyValue(String name) { 1120 this(name, null); 1121 } 1122 1123 GTKLazyValue(String name, String methodName) { 1124 this.className = name; 1125 this.methodName = methodName; 1126 } 1127 1128 public Object createValue(UIDefaults table) { 1129 try { 1130 Class<?> c = Class.forName(className, true,Thread.currentThread(). 1131 getContextClassLoader()); 1132 1133 if (methodName == null) { 1134 return c.newInstance(); 1135 } 1136 Method m = c.getMethod(methodName, (Class<?>[])null); 1137 1138 return m.invoke(c, (Object[])null); 1139 } catch (ClassNotFoundException cnfe) { 1140 } catch (IllegalAccessException iae) { 1141 } catch (InvocationTargetException ite) { 1142 } catch (NoSuchMethodException nsme) { 1143 } catch (InstantiationException ie) { 1144 } 1145 return null; 1146 } 1147 } 1148 1149 static { 1150 CLASS_SPECIFIC_MAP = new HashMap<String,String>(); 1151 CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width"); 1152 CLASS_SPECIFIC_MAP.put("Slider.thumbWidth", "slider-length"); 1153 CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border"); 1154 CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size"); 1155 CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width"); 1156 CLASS_SPECIFIC_MAP.put("ScrollBar.width", "slider-width"); 1157 CLASS_SPECIFIC_MAP.put("TextArea.caretForeground", "cursor-color"); 1158 CLASS_SPECIFIC_MAP.put("TextArea.caretAspectRatio", "cursor-aspect-ratio"); 1159 CLASS_SPECIFIC_MAP.put("TextField.caretForeground", "cursor-color"); 1160 CLASS_SPECIFIC_MAP.put("TextField.caretAspectRatio", "cursor-aspect-ratio"); 1161 CLASS_SPECIFIC_MAP.put("PasswordField.caretForeground", "cursor-color"); 1162 CLASS_SPECIFIC_MAP.put("PasswordField.caretAspectRatio", "cursor-aspect-ratio"); 1163 CLASS_SPECIFIC_MAP.put("FormattedTextField.caretForeground", "cursor-color"); | 1114 * Name of the class to create. 1115 */ 1116 private String className; 1117 private String methodName; 1118 1119 GTKLazyValue(String name) { 1120 this(name, null); 1121 } 1122 1123 GTKLazyValue(String name, String methodName) { 1124 this.className = name; 1125 this.methodName = methodName; 1126 } 1127 1128 public Object createValue(UIDefaults table) { 1129 try { 1130 Class<?> c = Class.forName(className, true,Thread.currentThread(). 1131 getContextClassLoader()); 1132 1133 if (methodName == null) { 1134 return c.getDeclaredConstructor().newInstance(); 1135 } 1136 Method m = c.getMethod(methodName, (Class<?>[])null); 1137 1138 return m.invoke(c, (Object[])null); 1139 } catch (ReflectiveOperationException e) { 1140 } 1141 return null; 1142 } 1143 } 1144 1145 static { 1146 CLASS_SPECIFIC_MAP = new HashMap<String,String>(); 1147 CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width"); 1148 CLASS_SPECIFIC_MAP.put("Slider.thumbWidth", "slider-length"); 1149 CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border"); 1150 CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size"); 1151 CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width"); 1152 CLASS_SPECIFIC_MAP.put("ScrollBar.width", "slider-width"); 1153 CLASS_SPECIFIC_MAP.put("TextArea.caretForeground", "cursor-color"); 1154 CLASS_SPECIFIC_MAP.put("TextArea.caretAspectRatio", "cursor-aspect-ratio"); 1155 CLASS_SPECIFIC_MAP.put("TextField.caretForeground", "cursor-color"); 1156 CLASS_SPECIFIC_MAP.put("TextField.caretAspectRatio", "cursor-aspect-ratio"); 1157 CLASS_SPECIFIC_MAP.put("PasswordField.caretForeground", "cursor-color"); 1158 CLASS_SPECIFIC_MAP.put("PasswordField.caretAspectRatio", "cursor-aspect-ratio"); 1159 CLASS_SPECIFIC_MAP.put("FormattedTextField.caretForeground", "cursor-color"); |