If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Trusted Contributor
QuestionMan
Posts: 167
Registered: ‎06-30-2011
My Device: n/a
My Carrier: Koodo
Accepted Solution

How to center image (.png)?

[ Edited ]

Hi its the noobie again. Using the following code setup, how can I include a Field command? (I want to center it)

 

        mainLogo = Bitmap.getBitmapResource("mainLogo.png");
        bitmap = new BitmapField();
        bitmap.setBitmap(mainLogo);
        fieldManagerMid.add(bitmap);

 

Also if someone could tell me the command to change a buttons font (if its just a simple command)

Thanks so much guys!

Please use plain text.
New Contributor
Nandita
Posts: 7
Registered: ‎05-09-2011
My Device: Torch
My Carrier: Developer

Re: How to center image (.png)?

Try this for centering the bitmap field

 

        mainLogo = Bitmap.getBitmapResource("mainLogo.png");
        bitmap = new BitmapField(BitmapField.HCENTER);
        bitmap.setBitmap(mainLogo);
        fieldManagerMid.add(bitmap);

 

For setting buttons font,try the below function

 

Font f = Font.getDefault().derive(Font.PLAIN, 16);

Mybutton.setFont(f);

Please use plain text.
Developer
simon_hain
Posts: 15,892
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to center image (.png)?

you can also create a custom layout manager to place fields:
http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

depending on the manager the HCENTER flag may not be adhered to, you can add the flag to the manager as well, then.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Trusted Contributor
QuestionMan
Posts: 167
Registered: ‎06-30-2011
My Device: n/a
My Carrier: Koodo

Re: How to center image (.png)?

thanks the image centred perfect.

 

But for the LabelField font, how could you adjust something like this?

 

LabelField title = new LabelField(" Hello ", LabelField.USE_ALL_WIDTH|DrawStyle.HCENTER);

Please use plain text.