-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On 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
Hi,
The
function
public
UiJTable getBasicTable() {
}
on
clientside (inside UIExtendedTable) should give you access to the underlying
swing table (UiJTable is a child of JTable).
And
you surely want to move the UIExtendedTable to an own class that will be
deployed/downloaded on the client side :-)
Best
regards,
Ilja Pavkovic
- [ULC-developer] Is it possible to get hold of the u... Behera, Prasanta Kumar
- RE: [ULC-developer] Is it possible to get hold... Janak Mulani
- RE: [ULC-developer] Is it possible to get ... Behera, Prasanta Kumar
- RE: [ULC-developer] Is it possible to ... Janak Mulani
- RE: [ULC-developer] Is it possible... Behera, Prasanta Kumar
- RE: [ULC-developer] Is it possible... Behera, Prasanta Kumar
- RE: [ULC-developer] Is it possible to get hold... Pavkovic, Ilja
- RE: [ULC-developer] Is it possible to get ... Behera, Prasanta Kumar
- RE: [ULC-developer] Is it possible to get hold... Pavkovic, Ilja
