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
Developer
saravanaboopati
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
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

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.
Found a bug? Report it using Issue Tracker
Developer
saravanaboopati
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
RexDoug
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)