Hi Fabien, Firstly, a guaranteed response time please subscribe to ULC Premium Support.
Which version of ULC are you using? We fixed https://www.canoo.com/jira/browse/UBA-7572 in ULC 2008 u1. If you are using a version later than ULC 2008 u1 then can you please explain your problem with respect to the snippet at the end? Note: >From 17.11.2010 Canoo is moving to Forum based support in place of mailing list based support. Can you please post on ULC Premium Support Forum at http://riasuite.canoo.com/forum/. You can use your ULC Premium Support userid and password to log in to the forum. Thanks and regards, Janak -------------------------- email: [email protected] http://www.canoo.com http://ulc.canoo.com ---------------------------- From: [email protected] [mailto:[email protected]] On Behalf Of Fabien RIVOISY Sent: 08 November 2010 22:03 To: [email protected] Subject: [ULC-developer] ULCTable with setAutoCreateRowSorter = true and columnModel with a DefaultTableCellRenderer to put a special icon Hi, i have a ulctable and i set the setAutoCreateRowSorter = true. In this table i have define some column with a defaultTableCellRenderer to put special icon depend of the value. When i make sort on any column then all columns are sorted except the column with defaultTableCellRenderer. Each time the method getTableCellRendererComponent give me the value at the first time. Have you got some special method or special renderer's class for a sort table? Thanks Fabien --------------------- import com.ulcjava.base.application.AbstractApplication; import com.ulcjava.base.application.IRendererComponent; import com.ulcjava.base.application.ULCBoxPane; import com.ulcjava.base.application.ULCFrame; import com.ulcjava.base.application.ULCScrollPane; import com.ulcjava.base.application.ULCTable; import com.ulcjava.base.application.table.AbstractTableModel; import com.ulcjava.base.application.table.DefaultTableCellRenderer; import com.ulcjava.base.application.table.ULCTableColumn; import com.ulcjava.base.application.util.Color; import com.ulcjava.base.development.DevelopmentRunner; public class TableRowSorterSnippet extends AbstractApplication { public void start() { final ULCTable table = new ULCTable(new SnippetTableModel(4, 2)); table.setAutoCreateRowSorter(true); ULCTableColumn column = table.getColumnModel().getColumn(0); column.setCellRenderer(new IconTableCellRenderer(table, 0)); ULCBoxPane content = new ULCBoxPane(true); ULCScrollPane scp = new ULCScrollPane(table); content.add(ULCBoxPane.BOX_EXPAND_EXPAND, scp); ULCFrame frame = new ULCFrame("TableRowSorterSnippet"); frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); frame.add(content); frame.setSize(300, 300); frame.setVisible(true); } public static void main(String[] args) { DevelopmentRunner.setApplicationClass(TableRowSorterSnippet.class); DevelopmentRunner.run(); } private static class SnippetTableModel extends AbstractTableModel { private int rowCount; private int columnCount; private Object[][] rows; public void clear() { rowCount = 0; rows = null; } public SnippetTableModel(int rowCount, int columnCount) { this.rowCount = rowCount; this.columnCount = columnCount; createColumnNames(columnCount); rows = createRows(rowCount, columnCount); } private static Object[][] createRows(int rowCount, int columnCount) { Object[][] result = new Object[rowCount][]; for (int i = 0; i < rowCount; i++) { result[i] = new Object[columnCount]; for (int j = 0; j < columnCount; j++) { if (j == 0) result[i][j] = i; else result[i][j] = i + ":" + j + " AAAa"; } } return result; } private static String[] createColumnNames(int columnCount) { String[] result = new String[columnCount]; for (int i = 0; i < columnCount; i++) { result[i] = Integer.toString(i); } return result; } public int getColumnCount() { return columnCount; } public int getRowCount() { return rowCount; } public Object getValueAt(int row, int column) { if (rows != null) return rows[row][column]; return null; } } class IconTableCellRenderer extends DefaultTableCellRenderer { private ULCTable fTable; private int fColumn; public IconTableCellRenderer(ULCTable table, int column) { fTable = table; fColumn = column; } public IRendererComponent getTableCellRendererComponent(ULCTable table, Object value, boolean isSelected, boolean hasFocus, int row) { value = fTable.getValueAt(row, fColumn); if (value != null && ((Integer)value) == 0) setBackground(Color.yellow); else if (value != null && ((Integer)value) == 1) setBackground(Color.green); else if (value != null && ((Integer)value) == 2) setBackground(Color.red); else setBackground(Color.magenta); return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row); } } } _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
