Hi,
I have problems with the width of the columns of a TreeTable. I think the problem is, that I populate the table after its column sizes are calculated. In my case the user has to populate it. So when the table is created its second column is empty.
There are 2 columns. The first should be as large as it can be and the second should have exactly the width it needs to show everything in every row. But at the moment, when I add some rows, the second column is far too small. So I want the table to recalculate the widths of the columns. But I’ve no idea how…
Update:
I partially solved that problem. I set the value of alwaysRecalculateColumnWidths to true in the constructor and everytime the user adds or removes some leaves I reset the sizes of the columns.
This works as long as the user doesn’t expand or callapse any node. When he does, the columns are automatically set to some stupid size I can’t comprehend.
So I’ve added a Collapse- and an ExpandListener and there I set the value of alwaysRecalculateColumnWidths to false. I have to set it to true again when leaves are added or removed. The code now looks like this
//in the constructor:
...
addCollapseListener(new CollapseListener() {
private static final long serialVersionUID = -7408116127729925600L;
@Override
public void nodeCollapse(CollapseEvent event) {
alwaysRecalculateColumnWidths = false;
}
});
addExpandListener(new ExpandListener() {
private static final long serialVersionUID = 3181411092615125578L;
@Override
public void nodeExpand(ExpandEvent event) {
alwaysRecalculateColumnWidths = false;
}
});
}
And in the Adder I call
private void refreshColumnSizes() {
alwaysRecalculateColumnWidths = true;
setColumnWidth("secondColumn", -1);
setColumnExpandRatio("firstColumn", 1.f);
}
But now I still have the problem that when a node is collapsed, leaves are added to it and then the node is expanded again, the columns aren’t resized.
What I need is a listener that is called AFTER the nodes are expanded/collapsed. Because the listeners mentioned above are called before. So every resizing there is effectless.
Or a TreeTable that behaves like it should, that would be even better