Salut Daniel,
You should do the same that Swing is doing do calculate the preferred
width of the columns header text:
private Component getHeaderRenderer(int columnIndex) {
TableColumn aColumn = header.getColumnModel().getColumn
(columnIndex);
TableCellRenderer renderer = aColumn.getHeaderRenderer();
if (renderer == null) {
renderer = header.getDefaultRenderer();
}
return renderer.getTableCellRendererComponent(header.getTable
(),
aColumn.getHeaderValue(),
false, false,
-1, columnIndex);
}
Then invoke getPreferredSize() on the returned component, this will
return you the width of the columns header text.
Remember that you have to do this on the client side => http://
lists.canoo.com/mailman/private/ulc-developer/2007/005587.html
Regards Dany
On 20.09.2007, at 13:30, [EMAIL PROTECTED] wrote:
Hello,
does anyone know a good way to implement the calculation of the
perfectly
matching column width, depending on the columns header text, like
you can
do in Swing using the following snippet?
Font font = table.getFont();
FontMetrics fontMetrics = table.getFontMetrics(font);
int width = SwingUtilities.computeStringWidth (fontMetrics,
headerText);
Thanks and regards,
Daniel_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer