/** * Get the appropriate editor for the given property. * * @param prop Property to get editor for. * @return Editor to use, or null if none found. */ private PropertyEditor getEditorForProperty(PropertyDescriptor prop) { PropertyEditor retval = null; Class type = prop.getPropertyEditorClass(); if (type != null) { try { retval = (PropertyEditor) type.newInstance(); } catch (Exception ex) { ex.printStackTrace(); } } // Handle case where there is no special editor // associated with the property. In that case we ask the // PropertyEditor manager for the editor registered for the // given property type. if (retval == null) { Class t = prop.getPropertyType(); if (t != null) { retval = PropertyEditorManager.findEditor(t); } } // In the worse case we resort to the generic editor for Object types. if (retval == null) { retval = PropertyEditorManager.findEditor(Object.class); } return retval; }