Skip to main content

2 Questions about TextArea

9 replies [Last post]
fisher55
Offline
Joined: 2008-09-18
Points: 0

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
this problem will occur since TextArea's initRowString assumes that
'W' is the widest char in a phone. This is untrue for CJK languages
on all devices, however this assumption is necessary since CJK isn't
supported on most devices and some devices have a huge performance
issue for charWidth/charsWidth.
I can solve this by adding a setLargestChar(char) method but I would
like you to confirm that this is indeed the issue by replacing the
'W' in the iniRowString method with your widest character.

> I have 2 questions about TextArea:
>
> [b]1. The first one is about split lines.[/b]
> I am a chinese developer, and I use TextArea to display chinese.
> Whatever the width of the TextArea, the TextArea can not
> display the text fully in a line. for example:
> the text is "ABCDEFGHIJKLMNOP"
> the TextArea will show
> "ABCD"(EF can't be seen)
> "GHIJ" (KL can't be seen)
> "MNOP"
> Acorrding to this width of TextArea, the right displaying
> should like this:
> "ABCD"
> "EFGH"
> "IJKL"
> "MNOP"
>
> (English text is just for example to easy describe, in fact I
> will use text like "同样是秋天进行时的美国,大明星
> 们又在引导那些潮流呢")
>
> [b] It only happen when text is chinese. The split lines of
> English text is always right.[/b]
> So I think that width of chinese text in TextArea maybe is wrong.
>
>
> [b]2. How the set the text split sign[/b]
> For my testing, the space bewteen chinese word or the "\n" will
> cause adding a line.
> Is there a function to set or change the sign? Because
> sometimes I don't wanna "space" be a split sign.
> [Message sent by forum member 'fisher55' (fisher55)]
>
> http://forums.java.net/jive/thread.jspa?messageID=304144
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

fisher55
Offline
Joined: 2008-09-18
Points: 0

Shai Almog,
Thank you very much.
I really want to solve this problem in my app.
But different with English, there are so many word in Chinese language and I don't know which is the widest character. And I am not sure whether I can call the function like this: setLargestChar('宽');
So could you give a function to set the width directly. for example:
setLargestCharWidth(int width)

How do you think so?
Thx for replying.

fisher

Shai Almog

Hi,
that would be a problem since the font might be changed in runtime
thus changing the width of the widest character.
If a character would be slightly bigger that won't be a big problem
since we allow some room for error, the main problem is in characters
that are much wider than W in the given font on the device.

> Shai Almog,
> Thank you very much.
> I really want to solve this problem in my app.
> But different with English, there are so many word in Chinese
> language and I don't know which is the widest character. And I am
> not sure whether I can call the function like this: setLargestChar
> ('宽');
> So could you give a function to set the width directly. for
> example:
> setLargestCharWidth(int width)
>
> How do you think so?
> Thx for replying.
>
> fisher
> [Message sent by forum member 'fisher55' (fisher55)]
>
> http://forums.java.net/jive/thread.jspa?messageID=304464
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

fisher55
Offline
Joined: 2008-09-18
Points: 0

Hi, Shai or Chen
About this problem, I have rewirted the initRowString() and solved my problem.
But I don't want to modify the LWUIT source code directly, I want to extends the TextArea and override this function to solve my private problem.
But many key member variables in TextArea such as rowStrings, text and so on is private. Could you change it to protected for extending?
Or is there another way to implement it?

Thank you

Shai Almog

Hi,
yes we can expose a setLargestChar(char) method if that would solve
your issue.

> Hi, Shai or Chen
> About this problem, I have rewirted the initRowString() and
> solved my problem.
> But I don't want to modify the LWUIT source code directly, I
> want to extends the TextArea and override this function to solve my
> private problem.
> But many key member variables in TextArea such as rowStrings,
> text and so on is private. Could you change it to protected for
> extending?
> Or is there another way to implement it?
>
> Thank you
> [Message sent by forum member 'fisher55' (fisher55)]
>
> http://forums.java.net/jive/thread.jspa?messageID=313658
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

hotszkin
Offline
Joined: 2008-11-23
Points: 0

Hi,

I am facing the the same problem. Can I open a RFE for this?

fisher55
Offline
Joined: 2008-09-18
Points: 0

One more detail things:
There is no problem in WTK2.5 emulator.
Bug only be found in real cellphone.
My test phone is Nokia N82.

I have no idea how to deal with this bug. :(

Thx a lot

abp_dk
Offline
Joined: 2008-12-30
Points: 0

fisher55,

Can you tell me what the widest char is in simplified chinese? In other words, what char should be used instead of the default 'w'?

Thanks,

Anders

abp_dk
Offline
Joined: 2008-12-30
Points: 0

Widest simplified chinese char seems to be '一'. Correct me if I'm wrong.

/Anders