Table.getColumn(0).pack() is 2 too low [message #559092] |
Wed, 15 September 2010 15:17 |
H. Niemann Messages: 5 Registered: September 2010 |
Junior Member |
|
|
Hello!
If I create a table and pack() it's columns,
the longest text in the first column does not fit and
is shortend and ... dots are added.
If I increase the width of the column after pack()ing by 2,
it works. Only column 0 is affected, as far as I can tell.
I can provide a screen shot by private mail.
Is this a known problem? How can I fix that, other than
increasing the width by hand?
With best regards
H. Niemann
--8<---------------------------
public void axisTable(Table table, int i)
{
int dim = this.getDimension();
table.setHeaderVisible(false);
table.setLinesVisible(true);
TableColumn col = new TableColumn(table, SWT.NULL); // Labels
col = new TableColumn(table, SWT.NULL); // X axis
TableItem line;
line = new TableItem(table, SWT.NULL);
line.setText(0, "Adding "+String.valueOf(i)+" to");
line.setText(1, "pack() result");
for (int ii = 0; ii < table.getColumnCount(); ii++)
{
table.getColumn(ii).pack();
}
col = table.getColumn(0);
col.setWidth(col.getWidth()+i);
table.pack();
}
|
|
|
Re: Table.getColumn(0).pack() is 2 too low [message #559593 is a reply to message #559092] |
Fri, 17 September 2010 10:25 |
|
Lakshmi P Shanmugam Messages: 279 Registered: July 2009 Location: India |
Senior Member |
|
|
Hi,
This works fine for me. Which platform are you using?
This is the snippet that works for me on windows. Can you try if it works fine for you? Can you modify this to show us the failing case?
public class Table_pack {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
table.setLinesVisible(true);
table.setHeaderVisible(false);
new TableColumn(table, SWT.NONE);
new TableColumn(table, SWT.NONE);
TableItem line;
line = new TableItem(table, SWT.NULL);
line.setText(0, "Adding to");
line.setText(1, "pack() result");
for (int ii = 0; ii < table.getColumnCount(); ii++) {
table.getColumn(ii).pack();
}
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Lakshmi P Shanmugam
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 5.03801 seconds