Project: SWT
Bug 129495 [Table] TableColumn#pack() no longer respects TableItem's Font
Reported: 2006-02-26 12:16:29 | Status: resolved fixed

The following snippet puts an "..." next to the TableItem's content. It uses bold Font which requires a bit more space than normal Font, but a pack on the TableColumn does not respect that. The snippet works with M4 and before: public class Main { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); FontData def[] = display.getSystemFont().getFontData(); Table t = new Table(shell, SWT.NONE); t.setHeaderVisible(true); TableColumn col = new TableColumn(t, SWT.NONE); col.setText("Hello"); TableItem item = new TableItem(t, SWT.NONE); item.setText("Hello World"); item.setFont(new Font(display, def[0].getName(), def[0].getHeight(), SWT.BOLD)); col.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } } This currently blocks my next release unfortunately. I hoped being able to run with M5. A workaround is to set the bold Font on the entire Table. However, that would show any TableColumn in Bold as well. Ben

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java