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


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.


Reply
Highlighted
Developer
Posts: 147
Registered: ‎09-10-2008
My Device: Not Specified
Accepted Solution

How to fix the height and width of the control field?

Hi,

I created a ButtonField I need to set the height and width of the field fixed. when the application shifted from one device to another device the button size vary and also the contents in the button field also shrink. I want to set fixed whenever I shifted my application to other device the display of the button must be fixed. how to achive this give me some code sample. I am new to blackberry.

BlackBerry Development Advisor
Posts: 15,889
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to fix the height and width of the control field?

A ButtonField's size changes based on the text within it.  Since different themes have different default fonts, along with the fact that a user can change the font, your ButtonfField's size could change.  To work around this, you can set the font for your button to keep the text size the same.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 147
Registered: ‎09-10-2008
My Device: Not Specified

Re: How to fix the height and width of the control field?

 Give me some clear idea in the code if possible.

I need the Button to be fixed throughout the devices. 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to fix the height and width of the control field?

Subclass ButtonField and override the getPreferredWidth() method.

 

class FixedWidthButtonField extends ButtonField{ private int width; FixedWidthButtonField( String label, int Width){ super( label); width = Width; } public int getPreferredWidth(){ return width; } }

 

(code by Jonathan Fisher)