Reputation: 13364
I have created a TextArea
with statement ....
quest1Label = new TextArea();
I am using the TextArea
for displaying the Labels
.... So I use following function to set its properties....
private void setTextAreaProperty(TextArea textArea) {
String textStr = textArea.getText();
if (textArea.getStyle().getFont().stringWidth(textStr) > (width - 25)) {
textArea.setSingleLineTextArea(false);
} else {
textArea.setSingleLineTextArea(true);
textArea.setPreferredW(width);
}
textArea.setBorderPainted(false);
textArea.setFocusable(false);
textArea.setStyle(getPreviewStyle());
}
where width = Display.getInstance().getDisplayWidth(); my problem is that up to two lines the label works properly but .... if the text is even larger it doesn't go to third line. any help regarding this will be appreciated.
Thanks in Advance,....
Upvotes: 2
Views: 2504
Reputation: 52745
You need to use the TextArea
constructor like this new TextArea(1, 20)
which allows the layout to "grow" more effectively.
The reason is mostly historic, LWUIT had a 3 column default for TexAarea
which allow the TexAarea
to shrink well but sucks when growing. The complexity in growing/shrinking is derived by the fact that layouts can be deeply nested and scrollable hence the available space vs. desired space calculation becomes recursive and at some hard to detect point unsolvable (infinite recursion).
Upvotes: 6
Reputation: 6447
Have you tried setGrowByContent? Maybe the default number of rows is 2, and it doesn't grow more than that.
Regards.
Upvotes: 2