Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Center Text

 
Steven Mann
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to center a drawText string for a Blackberry App I'm building, but I can't find a center function. So I devised a formula: Half the width of the screen minus half the width of the text. As far as I know, Java ME doesn't support font metrics, so I can't calculate the text width. Any Suggestions?
 
Gopinath Karyadath
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);

mytext= "helloworld"

textwidth = font.stringWidth(mytext) ;


regards


 
Steven Mann
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow! Thanks for the quick response! You have no idea how much stress you just relieved!
 
Gopinath Karyadath
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy to relieve your stress
regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic