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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 20
Registered: ‎05-17-2012
My Device: have no device
My Carrier: KievStar
Accepted Solution

Two buttons

I need make two buttons.

-first button at the left side of the display

-second button at the right side of the display


i try make like this but it dosn't work(


HorizontalFieldManager titleHFM = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
HorizontalFieldManager leftHFM = new HorizontalFieldManager(HorizontalFieldManager.FIELD_LEFT);
leftHFM.add(new ButtonField("Left"));
HorizontalFieldManager rightHFM = new HorizontalFieldManager(HorizontalFieldManager.FIELD_RIGHT);
rightHFM.add(new ButtonField("Right",ButtonField.RIGHT));

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Two buttons

[ Edited ]

Welcome to the forums.


I recommend that you use the EvenlySpacedHorizontalFieldmanager or HorizontalButtonFieldSet from here:


Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: Two buttons



You can get this by overridng sublayout of the title manager and no need to take seperate manager for each and every button.


Try like this,

HorizontalFieldManager titleHFM = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER)
            protected void sublayout(int maxWidth, int maxHeight)
                setPositionChild(getField(0), 0, 0);
                layoutChild(getField(0), getField(0).getPreferredWidth(),getField(0).getPreferredHeight());
                setPositionChild(getField(1), Display.getWidth() - getField(1).getPreferredWidth(), 0);
                layoutChild(getField(1), getField(1).getPreferredWidth(),getField(1).getPreferredHeight());
                setExtent(maxWidth, maxHeight);

titleHFM.add(new ButtonField("Left"));
titleHFM.addnew ButtonField("Right");



Lakshman K


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.

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Two buttons

I recommend you look at the code supplied in the KB article I previously pointed you at and use that code.  The samples supplied are well written and demonstrate best practice. 


Unfortunately the example given above by lakshman9687 has a number of issues.  For example, the last line

setExtent(maxWidth, maxHeight);

will grab the maximum amount of space for the Manager, in fact it only needs enough height for the two buttons.