Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
chengbang69
Posts: 62
Registered: ‎01-22-2010
My Carrier: Globe
Accepted Solution

Using ActiveRichTextField with USE_TEXT_WIDTH

[ Edited ]

I'm using JDE 4.3

 

I have 4 ActiveRichTextFields inside a HorizontalFieldManager:

 

 

public VvfUpperField(Font[] fonts, int[] backgroundColors, byte[] attributes, long style, QuotesConstants qc)
{
super(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL);

for(int n =1; n<=4; n++)
{
add(new ActiveRichTextField(" bbbbbbbbb ", qc.offsets3, attributes, fonts, qc.fg2, backgroundColors, (long)ActiveRichTextField.USE_TEXT_WIDTH));
}
}

 

the width of the ActiveRichTextField varies from the length of a text. But as a test, i placed " bbbbbbbb ". When i open the .cod file in any simulator (from 4.3-5.0) the project works perfectly. But when I try to debug it (whether in bb JDE  or eclipse 3.4) the program throws an "illegalArgumentException". When I checked the width of the ActiveRichTextFields, the width is set to -1.

 

i already tried searching using the search tool above but i can't find an answer. i know it's called text wrapping, but is there a style constant for this, without having to do my own method?

 

 

Please use plain text.
Developer
peter_strange
Posts: 17,712
Registered: ‎07-14-2008

Re: Using ActiveRichTextField with USE_TEXT_WIDTH

With a RichTextField, the String that is passed in is formatted according to the Fonts and offsets passed in.  This KB article explains this process:

 

How To - Format text in a RichTextField
Article Number: DB-00124
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

If you have a sequence of Fonts and Offsets, and then supply the Field with an arbitrary String, which is what you seem to be doing, then it might not like the combination.  Ii this what is happening?

Please use plain text.
Developer
chengbang69
Posts: 62
Registered: ‎01-22-2010
My Carrier: Globe

Re: Using ActiveRichTextField with USE_TEXT_WIDTH

no, i've already set the offsets based on the test string. I was  trying to adjust the width of the ActiveRIchTextField based on the supplied string.

 

I was using ActiveRichTextField since it accepts foreground color parameters. Thanks to the KB article, i looked at the RichTextField class and realized that i can overide the paint method of RichTextField. The KB article was really helpful, thanks!:smileyvery-happy:

Please use plain text.