I use Vaadin's GridLayout for visualization of some title and value labels. The GridLayout has 2 columns and several rows. Title labels are on the left side and their associated value labels on the right.
I want the first column to consume as less space as possible and the second column should occupy all the remining space of the browser's window. If a value label requires more space than available then it must break the line.
I tried to play with setColumnExpandRatio()
. If I determine following ratio for the second column (and omit a ratio specification for the first column) then everything works as requested except the fact that value labels with very large textual content don't break at the line's end. Instead, a horizontal scroll bar appears:
public class MyPanel extends GridLayout
{
public MyPanel()
{
setWidth("100%");
setMargin(true);
setSpacing(true);
buildView();
}
public void buildView()
{
removeAllComponents();
setColumns(2);
setColumnExpandRatio(1, 1);
...
titleLabel.setWidth(null);
valueLabel.setWidth(null);
addComponent(titleLabel);
addComponent(valueLabel);
setComponentAlignment(titleLabel, Alignment.TOP_RIGHT);
}
}
If I also specify a ratio for the first column then the first column consumes more space than really needed.
How can I realize my requirements?