View Full Version : Anyone can give me a tips using richclient table component?
gispda
Aug 15th, 2004, 10:05 AM
Hi all!
I am confusing to how to code this using richclient table component,give a table sample.
thinks.
Keith Donald
Aug 15th, 2004, 01:11 PM
The simplest method to call, assuming you don't mind working with a standard JTable, is TableUtils.createStandardSortableTable(tableModel) . Just define a table model adapter for your data, and pass it in as a parameter to this method. You'll get back a fully multi-column sortable table with default renderers installed for common column types. See the BaseTableModel/BeanTableModel classes for convenient table model superclasses.
public static JTable createStandardSortableTable(TableModel tableModel) {
JTable table = new JTable();
ShuttleSortableTableModel sortedModel = new ShuttleSortableTableModel(
tableModel);
table.setAutoCreateColumnsFromModel(true);
table.setModel(sortedModel);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
installDefaultRenderers(table);
TableSortIndicator sortIndicator = new TableSortIndicator(table);
new SortTableCommand(table, sortIndicator.getColumnSortList());
sizeColumnsToFitRowData(table);
return table;
}
smv
Aug 15th, 2004, 09:15 PM
I implemented a JTable using the method Keith describes above, only to spend some time trying to figure out why my Boolean would not render as a JCheckBox. That method also overrides the default renderers with ones defined in Spring-RCP. As for my case of trying to get Boolean as a JCheckBox, the Spring-RCP BooleanTableCellRenderer extends DefaultTableCellRenderer (by way of OptimizedTableCellRenderer), which is a JLabel.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.