Skip to main content

Is there any function make lwuit - List line wrapping?

7 replies [Last post]
billshw
Offline
Joined: 2009-04-07

Is there any function make lwuit - List line wrapping when the string is too long to display?

Please Help~
Thanks a lot.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
maoxuchu
Offline
Joined: 2009-03-12

I also need a list which can have variable heights, can someone post some code about this

saturon

No, but this would be actually something that we could put as feature
request, for text fields as well as for labels.

What I do because of this problem is I always use a custom textarea
instead of labels and calculate available space programmatically if its
gonna be a single-line or multiline.

-----Original Message-----
From: lwuit-users@mobileandembedded.org
[mailto:lwuit-users@mobileandembedded.org]
Sent: Dienstag, 7. April 2009 11:21
To: users@lwuit.dev.java.net
Subject: Is there any function make lwuit - List line wrapping?

Is there any function make lwuit - List line wrapping when the string is
too long to display?

Please Help~
Thanks a lot.
[Message sent by forum member 'billshw' (billshw)]

http://forums.java.net/jive/thread.jspa?messageID=340921

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

ghady_rayess
Offline
Joined: 2009-01-09

I checked the implementation of TextArea class. and i noticed that they specifically disable automatic multiline support if the TextArea is initially instantiated to one row.
If u comment that section out, it would be possible to create a TextArea with a single row, and can grow based on need.

The code is in the function [b]private void initRowString()[/b]
===========
// single line text area is essentially a text field
if(rows == 1) {
rowStrings.addElement(getText());
return;
}
============

if it doesn't affect other behavior in the TextArea, i would recommend someone from the editors to comment this section out and commit a change to the SVN

juliofabio
Offline
Joined: 2009-02-10

Instead of change the source of TextArea, try to use the combinations of myListTextArea.setRows(2); myListTextArea.setGrowsByContent(true).

but, if I understood what you want, the List component do not work with variable (mutant) lines height.

If some one had resolved this situation, please, post the code. I am testing my own ListControl with mutant items height.

Best regards,

juliofabio

ghady_rayess
Offline
Joined: 2009-01-09

Hi Juliofabio,
The problem with setting the rows to 2: [b]myListTextArea.setRows(2)[/b] is that i will have the minimum height of the component to two lines/rows even when the text needs one line.
I would like to have a generic TextArea which starts with [b]one[/b] and can grow automatically.

Regards,

Klemens

You can override the setText() method of the TextArea and set rows to 1
or more depending on the width of the text. I'm pretty sure example code
has for this has been posted in this forum already.

On 16.04.2009 18:13, lwuit-users@mobileandembedded.org wrote:
> Hi Juliofabio,
> The problem with setting the rows to 2: [b]myListTextArea.setRows(2)[/b] is that i will have the minimum height of the component to two lines/rows even when the text needs one line.
> I would like to have a generic TextArea which starts with [b]one[/b] and can grow automatically.
>
> Regards,
> [Message sent by forum member 'ghady_rayess' (ghady_rayess)]
>
> http://forums.java.net/jive/thread.jspa?messageID=342435
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

ghady_rayess
Offline
Joined: 2009-01-09

I guess we are giving this issue more attention than it deserves.
Yes we can override setText() and get the component's Font and calculate the text length and the length of the container and check whether it will be spanning more that one line, and.... but wouldn't we be reinventing the wheel?!
The TextArea class is already doing all this trouble (automatic calculation of rows and the text painted in each row), but is disabled when num of rows is set to 1.
My question is, why is it disabled for rows=1 ?!?!