List of usage examples for java.beans BeanInfo getDefaultPropertyIndex
int getDefaultPropertyIndex();
From source file:org.springframework.richclient.table.renderer.BeanTableCellRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value != null) { if (beanWrapper == null) { beanWrapper = new BeanWrapperImpl(value); } else {/*from w w w.j a va 2 s. c o m*/ beanWrapper.setWrappedInstance(value); } try { BeanInfo info = Introspector.getBeanInfo(value.getClass()); int index = info.getDefaultPropertyIndex(); if (index != -1) { String defaultPropName = beanWrapper.getPropertyDescriptors()[index].getName(); Object val = beanWrapper.getPropertyValue(defaultPropName); TableCellRenderer r = table.getDefaultRenderer(val.getClass()); return r.getTableCellRendererComponent(table, val, isSelected, hasFocus, row, column); } } catch (IntrospectionException e) { log.debug("Error during introspection of bean: " + e.getMessage(), e); } } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); }