Skip to main content

WrapLabel TextArea row problem

2 replies [Last post]
jacostgroup
Offline
Joined: 2011-01-12
Points: 0

Hi

I am trying to use a TextArea as a WrapLabel

The only problem I have is it does not automatically change the number of rows when it grows
This leads to scroll problems, where the minum size of the component does not change

After I do a setText("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

I ask for the getRows , getLines and getActualRows they all return 1
even though there are now more than one line of text in the TextArea

If I do a setRows(3) it works, but that defies the purpose of my component.

Any ideas
Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
handylearn
Offline
Joined: 2010-02-17
Points: 0

I think I got the same problem.
I solved it by creating a class derived from TextArea and override the setWidth().
See details here:
http://www.java.net/forum/topic/mobile-embedded/lwuit/disable-extra-scro...

Regards

Karsten Meier

carsamba55
Offline
Joined: 2010-12-16
Points: 0

Try this: myTextArea.setGrowByContent(true);
If that doesn't work, try this, this is my "WrapLabel":
public final TextArea TextAreaLabel(final String text, final int bgColor) {
final TextArea tal = new TextArea(text);
tal.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
tal.setAlignment(TextArea.LEFT);
tal.getStyle().setMargin(0, 0, 0, 0);
tal.getStyle().setPadding(0, 0, 0, 0);
tal.getStyle().setBgColor(bgColor);
tal.getUnselectedStyle().setBorder(null);
tal.setEditable(false);
tal.setFocusable(false);
return tal;
}