Hi Prasanta, First of all you should never invoke restoreState() method in your code, it is invoked by ULC while managing the life cycle of the client side half object.
>But our project has an additional requirement. Our project has something >called a field chooser utility. When a user clicks on the field chooser >he gets a list of columns. The user can select any number of columns >that he would like to view and the table is refreshed with the selected >columns. While refreshing the table I am using >fireTableStructureChanged() method. When I call >fireTableStructureChanged() method it is removing the effect of word >wrapping in the column header. I am not very sure why it is behaving in >such a fashion. When you do fireTableStructureChanged() all columns of the table are recreated if you have autoCreateColumnsFromModel set to true. This is the reason why all renderers including those for headers are lost. There are two solutions: 1. Set renderers on the columns again immediately after you do fireTableStructureChanged(). Or 2. Set autoCreateColumnsFromModel to false and create and add columns to the table programmatically. Add your renderers to these columns. Keep this set of columns in a collection. Subsequently in your field chooser utility you can selectively add or remove columns to your table from this collection. I hope this helps. Thanks and regards, Janak -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Behera, Prasanta Kumar Sent: Wednesday, July 26, 2006 7:42 AM To: [email protected] Subject: [ULC-developer] Is it possible to get hold of the underlying Swing table from ULCTable? Hi All, Is it possible to get hold of the underlying swing table from the ULCTable? In order to achieve wrapping in the column header I have done the following: Created both extended ULCTable and UITable class. The ULC class just overrides typeString() and the UI class restoreState(). The text area renderer component is eventually set on the underlying Swing table in the restoreState() method after calling super(). Code Snippet is as given below: protected String typeString() { // works only in development mode; to be replaced by a full-qualified package string return UIExtendedTable.class.getName(); } public static class UIExtendedTable extends UITable { public void restoreState(Anything args) { super.restoreState(args); JWordWrapTableHeader headerRenderer = new JWordWrapTableHeader(); for (Enumeration enumeration = getBasicTable().getColumnModel() .getColumns(); enumeration.hasMoreElements();) { TableColumn column = (TableColumn) enumeration.nextElement(); column.setHeaderRenderer(headerRenderer); } } private static class JWordWrapTableHeader extends JTextArea implements TableCellRenderer { public JWordWrapTableHeader() { setLineWrap(true); setWrapStyleWord(true); setBackground(new Color(223, 235, 252)); setBorder(UIManager.getBorder("TableHeader.cellBorder")); } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { setText((String) value); setSize(table.getColumnModel().getColumn(column).getWidth(), getPreferredSize().height); return this; } } } But my project has an additional requirement. My project has something called a field chooser utility. When a user clicks on the field chooser he gets a list of columns. The user can select any number of columns that he would like to view and the table is refreshed with the selected columns. While refreshing the table I am using fireTableStructureChanged() method. When I call fireTableStructureChanged() method it is removing the effect of word wrapping in the column header. I need to set the renderer again on the underlying Swing table. Is it possible to get hold of the underlying Swing table from ULCTable? If this is possible I can again set the renderer on the underlying Swing table after calling fireTableStructureChanged() method? If this is not possible is there a way to set the renderer again after calling fireTableStructureChanged() method? Thanks & Regards Prasanta _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
