It would seem a simple thing to do, no? In fact, positioning/aligning text has become such an abundant demand over the last few years, that the ability to do so in most environments is fairly trivial. And if you’re working predominantly in the web field, it’s a no-brainer. The native Java components for BlackBerry are a little different however.
An exhaustive search on RIMs support forums and in general, “the internet” reveals many a frustrated developer struggling with the right-alignment of text within a field. I’m emphasizing that since there’s also a lot of confusion with right-aligning the field itself; an entirely different and altogether more straightforward task.
The gritty: you need to handle drawing the text yourself.
* blank out the field entirely (i.e. fill the background with white paint)
* drawText() in your label at 0, 0
* drawText() in your text with DrawStyle.RIGHT
* fillRect() a cursor at the right hand side of the input field
maintain a local copy of the text value of the field
Along the way I started stumbling across other ideas for highlighting the input field and making it a little more catchy for the user.
Here’s a screenshot of my custom input field with the focus.
You’ll notice the default field below it (R120) is the BlackBerry standard BasicEditField. The R1234 field is my custom field, with highlighted background, slightly pronounced text and right-aligned with a dark cursor on the right edge.
Kudos, references and inspiration drawn from: