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.

inside custom component

Java Development

Reply
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Aligning a BasicEditField's to the right

Hello,

 

I have an HorizontalFieldManager containing a RichTextField and a BasicEditField.

 

The richtextfield is created as follow:

 

RichTextField label = new RichTextField(labelName, RichTextField.NON_FOCUSABLE | RichTextField.USE_TEXT_WIDTH) { protected void paint(Graphics graphics) { graphics.setBackgroundColor(leftColor); graphics.clear(); super.paint(graphics); } };

 How can I align the BasicEditField so that its on the right of the screen?

I trie

 

 

editField = new BasicEditField("", defaultValue, EditField.DEFAULT_MAXCHARS, EditField.NO_NEWLINE | Field.FIELD_RIGHT) { protected void paint(Graphics graphics) { graphics.setBackgroundColor(rightColor); graphics.clear(); super.paint(graphics); } public int getPreferredWidth() { return getScreen().getWidth() / 2; } };

 

 but it doesn't work. I guess Field.Right doesnt do anything since the field is expanding to the whole HorizontalFieldManager width so I tried getprefereedwidth without sucess.

any idea? thanks

 

 

 

Highlighted
BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Aligning a BasicEditField's to the right

Add the DrawStyle.RIGHT style to your BasicEditField to right justify the text.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker