BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 01-09-2009, 11:35 PM   #1
patokike
New Member
 
Join Date: Jan 2007
Location: Chile
Model: 8100
Carrier: Entel PCS
Posts: 14
Exclamation Fixed width button trick not working correctly...

Please Login to Remove!

I have tested the trick given here
BlackBerry Fixed Width ButtonField (also here http://www.blackberryforums.com/deve...set-width.html)

... plus adding a Style so can be centered
my idea was to make it 30 pixels less than the screen width
so.. I have this
Code:
public class FixedWidthButtonField extends ButtonField{
    private int width;
 
    FixedWidthButtonField( String label, int Width){
        super( label, ButtonField.FIELD_HCENTER);
        width = Width;
    }
 
    public int getPreferredWidth(){
        return width;
    }
}
and in the screen
Code:
...
FixedWidthButtonField _bf = new FixedWidthButtonField("Test", Display.getWidth() - 30);
add(_bf);
...
with this I get the button centered, by the text in it isn´t centered!!



I´m using JDE 4.5.0
any ideas??

Thanks in advance...
Offline  
Old 01-10-2009, 08:41 PM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

Field.FIELD_HCENTER only centers the Field object within the manager.

To center the text, add DrawStyle.HCENTER to the style parameter.
Offline  
Old 01-10-2009, 11:04 PM   #3
patokike
New Member
 
Join Date: Jan 2007
Location: Chile
Model: 8100
Carrier: Entel PCS
Posts: 14
Default

Thanks Dougsg38p
but your solution doesn't change anything. I'm still seeing the text aligned to the left in the button

Do you think it has something to do with my JDE version?

Thanks for your time.
Offline  
Old 06-03-2009, 08:48 AM   #4
Swiebertje
New Member
 
Join Date: Apr 2009
Model: 9500
PIN: N/A
Carrier: Vodafone
Posts: 1
Default

Did you find a solution for this?
Offline  
Old 10-06-2009, 11:47 AM   #5
ddragoste
New Member
 
Join Date: Oct 2009
Model: 8900
PIN: N/A
Carrier: Vodafone
Posts: 1
Default

If it still matters ....
To center the text in the button,
override paint in FixedWidthButtonField with something like:

Font font = Font.getDefaultFont();
int textWidth = font.stringWidth(getLabel());
g.drawText(getLabel(), (width - textWidth) / 2, 0);
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Genuine Dell OEM G Series G7 7790 CPU and Graphics Heatsink Assembly XRF05 picture

Genuine Dell OEM G Series G7 7790 CPU and Graphics Heatsink Assembly XRF05

$20.30



OEM Dell latitude E7250 CPU Cooling Fan with Heatsink DP/N 04T1K3 0J3M4Y picture

OEM Dell latitude E7250 CPU Cooling Fan with Heatsink DP/N 04T1K3 0J3M4Y

$13.90



Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI picture

Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI

$94.99



1PCS NEW FIT FOR OEM Dell AC Adapter Dell Alienware DA330PM190 LA330PM190 330W picture

1PCS NEW FIT FOR OEM Dell AC Adapter Dell Alienware DA330PM190 LA330PM190 330W

$117.97



OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5 picture

OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5

$12.11



DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X  - Made By DELL picture

DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X - Made By DELL

$39.98







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