Gauvain Klug
Gauvain Klug

Reputation: 591

How to reduce the width of a TextArea used as String?

Still on my sidemenu from there, I've resolve the non broking text with a custom function that modify the text.

Now I'm stuck with the width of the component. I've change it from a SpanLabel to a TextArea in order to have more control on it's behaviour, but here is my problem: the TextArea width is too large as shown on the screenshot (put a ContentContainer UIID on to see the space occupied by the TextArea).

enter image description here

As you can see, the first component has a too large TextArea. I've set the column count of the TextArea to the length of the firstRow + 1, but it doesn't seem to take it in account.

The component is BorderLayout with a non grow center ScaleImageLabel and the TextArea on south. Is it a way to have a better width for the TextArea ? I would have it aligned with the image and with the area wrapped close to the text, but I really don't know how to achieve this...

Thanks in advance !

Upvotes: 1

Views: 46

Answers (1)

Diamond
Diamond

Reputation: 7483

My suggestion is to use GridLayout for equal sizes or TableLayout with constraints for varying sizes for left and right components. It will prevent the TextArea from growing beyond a limit.

An example will be:

//GridLayout
Container cont = GridLayout.encloseIn(4, cmpL1, cmpR1, cmpL2, cmpR2)

//OR

//TableLayout with Constraint
TableLayout tl = new TableLayout(2, 2);

Container cont = new Container(tl);
cont.add(tl.createConstraint().widthPercentage(50), cmpL1);
cont.add(tl.createConstraint().widthPercentage(50), cmpR1);
cont.add(cmpL2);
cont.add(cmpR2);

Upvotes: 3

Related Questions