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
rathinasamy
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer

How to increase the size of the buttonfield

Hi

 

   I have one button which in left allignment and i have given the label as signin and it shows in very small size, can anyone tell me how to increase the size of that button?? I want it to be displayed in very large size.

Please use plain text.
Developer
nitinverma274
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: How to increase the size of the buttonfield

I suggest you CustomButtonField.

Use the Search Button, You will find many Solution and threads releted to your thread.

------------------------------------------------------------------------------------

Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.

Please use plain text.
Developer
KushBB
Posts: 374
Registered: ‎04-07-2010
My Device: Bold 9000
My Carrier: Airtel

Re: How to increase the size of the buttonfield

[ Edited ]

Override the getPreferredWidth and getPreferredHeight function of the ButtonField as follows:

 

ButtonField cButton = new ButtonField("Signin",  ButtonField.CONSUME_CLICK) {

			public int getPreferredWidth()
			{
				int fieldWidth = 100; //required width
				return fieldWidth;
			}

			public int getPreferredHeight()
			{
				int fieldHeight = 20; // required height
				return fieldHeight;
			}
		};

 

Hope it Helps....

 

Press the Like button (Thumb up) on the left side to thank and
please mark the Thread as solved if its solved...
K.S
Please use plain text.
Trusted Contributor
rathinasamy
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer

Re: How to increase the size of the buttonfield

Thank you both guys

Please use plain text.
Developer
apjustin
Posts: 37
Registered: ‎05-27-2010
My Device: 9700 Storm

Re: How to increase the size of the buttonfield

Hi,

 

Create a custom class extending the field you want to modify and override getPrefferedWidth, then return the size you want in pixels.

 

class MyButtonField extends ButtonField
{
    private int width;

    MyButtonField( String label, int Width)
    {   super( label);
        width = Width;
    }
    public int getPreferredWidth()
    {   return width;
    }
}

 

Instantiate the Button like this 

 

private MyButtonField  btnB1 =  new MyButtonField( "Test", 100);

 

Height can also be changed like this

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Please use plain text.
Trusted Contributor
rathinasamy
Posts: 108
Registered: ‎09-03-2010
My Device: Not Specified
My Carrier: Developer

Re: How to increase the size of the buttonfield

Thank you for your solution

Please use plain text.
Developer
KushBB
Posts: 374
Registered: ‎04-07-2010
My Device: Bold 9000
My Carrier: Airtel

Re: How to increase the size of the buttonfield

Please mark the thread solved if you have got the solution...

Press the Like button (Thumb up) on the left side to thank and
please mark the Thread as solved if its solved...
K.S
Please use plain text.