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
Berrysoft
Posts: 143
Registered: ‎07-14-2008
Accepted Solution

Right Justify a RichTextField??

I can't seem to get a RTF to right justify!

 

 int[] offsets = { 0, 12, subHeadStr1.length() };
 byte[] attributes = { 0, 1 };
 RichTextField line1 = new RichTextField(subHeadStr1, offsets, attributes, fonts, RichTextField.NON_FOCUSABLE | RichTextField.FIELD_RIGHT);

 LabelField line2 = new LabelField(subHeadStr2, Field.NON_FOCUSABLE | Field.FIELD_RIGHT);
 line2.setFont(fonts[0]);
        
 VerticalFieldManager vfmSubHead = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | Field.NON_FOCUSABLE);
 vfmSubHead.add(line1);
 vfmSubHead.add(line2);

 

 

The "line2" LabelField gets right justified just fine, but not the RTF.

 

Any suggestions?

 

Please use plain text.
New Developer
Neil
Posts: 11
Registered: ‎07-14-2008

Re: Right Justify a RichTextField??

Please note I haven't tested this myself so this might just be a red-herring but looking at the documentation for RichTextField there are a number of static constants defined, one of which is TEXT_ALIGN_RIGHT. Any luck using this in place of FIELD_RIGHT?

 

Also, sometimes you can use DrawStyle constants. So if TEXT_ALIGN_RIGHT doesn't work try DrawStyle.RIGHT

 

Let me know how it goes.

 

Cheers,

Neil.

Please use plain text.