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
dmglakewood
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified
Accepted Solution

Easiest way to display text in a certain spot on the screen?

I was wondering what's the esiest way to display text on a sceen in a certain spot. For example I would like to disaply the word "Go" in the location (150, 200).

 

Is it possible to set the location of a  textfield using coordinates?

Please use plain text.
Developer
bneeman
Posts: 132
Registered: ‎02-11-2009
My Device: Not Specified

Re: Easiest way to display text in a certain spot on the screen?

I don't believe there's an "Absolute" layout manager. Did you consider over-riding paint(Graphics g). Calling super.paint(g) to do the real work. Then g.drawText("go", 150, 20)? Of course you need to g.setFont() and g.setColor() and do some math to get the text where you really want it.

 

Cheers, Barak.

 

Please use plain text.
Developer
dmglakewood
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified

Re: Easiest way to display text in a certain spot on the screen?

That worked perfectly thanks.

 

Is there anyway to right align the text though?

Please use plain text.
Developer
hippocamp
Posts: 21
Registered: ‎02-17-2009
My Device: Not Specified

Re: Easiest way to display text in a certain spot on the screen?

use Display.getWidth(); to get the screen size then myFont.getAdvance(myString); (to get the display width of the string) with some simple logic to figure out where to put the text
Please use plain text.
New Developer
mike240se
Posts: 113
Registered: ‎02-21-2009
My Device: Not Specified

Re: Easiest way to display text in a certain spot on the screen?

 dmg, did this turn out the best way to do this?  i noticed you got it right in storm slots.  i also want to display text in specific places like you did in storm slots.
Please use plain text.
Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Easiest way to display text in a certain spot on the screen?

Hi,

 

I think you can use drawText() with takes anchor point as its parameter.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.