BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-30-2008, 01:34 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2008
Model: 8130
PIN: N/A
Carrier: US Cellular
Posts: 82
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default drawText HCENTER

Please Login to Remove!

I can't seem to get drawText to horizontally center text on my anchor point. It is always left-aligned.

g.drawText("Test", getWidth()/2, getHeight()/2, DrawStyle.HCENTER);

getWidth and getHeight are returning proper values, and the point is in the center of the display when halved. Any suggestions?
Offline  
Old 08-30-2008, 08:25 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2008
Model: 8130
PIN: N/A
Carrier: US Cellular
Posts: 82
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

To answer my own question, it appears the API docs are flat-out wrong. It states that HCENTER centers text about the anchor point. Instead you have to specify the anchor as the left-most value of the box you want the text centered in, and provide the width of the drawing area:

g.drawText("Test", 0, getHeight()/2, DrawStyle.HCENTER, getWidth());
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Zebra ZQ520 Bluetooth IOS, Android, WM, BlackBerry Compatible - ZQ52-AUE0000-00
$595.0
Zebra ZQ520 Bluetooth IOS, Android, WM, BlackBerry Compatible - ZQ52-AUE0000-00 picture(A01) BLACKBERRY #PSMO5R-050CHW ADAPTER; In:100-240V 50-60Hz 0.15A;Out:5V 0.5A
$11.99
(A01) BLACKBERRY #PSMO5R-050CHW ADAPTER;  In:100-240V 50-60Hz 0.15A;Out:5V 0.5A pictureNEW OEM ORIGINAL BLACKBERRY MINI USB DATA CABLE ASY-06610-001 V3 5 FEET 1.5 M
$6.0
NEW OEM ORIGINAL BLACKBERRY MINI USB DATA CABLE ASY-06610-001 V3  5 FEET 1.5 M picture(A01) BlackBerry PSM04R-050CHW1(M) HDW-17957-003 Cell Phone Charger AC Adapter
$5.99
(A01) BlackBerry PSM04R-050CHW1(M) HDW-17957-003 Cell Phone Charger AC Adapter pictureNEW BlackBerry HDW-14322-001 OEM 3.5mm Stereo Headset Headphones Black Universal
$9.9
NEW BlackBerry HDW-14322-001 OEM 3.5mm Stereo Headset Headphones Black Universal picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.