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
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

CustomButton Use all Width

CustomButtons do not seem to take the .USE_ALL commands like the buttonfield, is there a way to incorporate this feature into the custombutton? If not I'd need to get the available width for the button, what might be the best way to go about doing this?

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

Re: CustomButton Use all Width

My experience is that the CustomButtons from these samples do USE-ALL_WIDTH.  So perhaps use one of these buttons or look at the code to see how to do it?

 

http://supportforums.blackberry.com/t5/Java-Development/Implement-advanced-buttons-fields-and-manage...

Developer
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: CustomButton Use all Width

Thanks Peter, by not using it I just mean, whereas a buttonfield will take:

final ButtonField Option2 = new ButtonField("Inactive",
ButtonField.USE_ALL_WIDTH)

 

A custombuttonfield does nto allow you to include a use all width like this when created. It returns that a long is not present in the constructor. I'll just use a different way

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

Re: CustomButton Use all Width

Not sure I understand what you are saying.

 

You are right that the standard RIM ButtonField does not use or respect USE_ALL_WIDTH.

 

But the CustomButtonField supplied in the sample code I pointed you at, does respect USE_ALL_WIDTH.  So if you used that Field instead of the standard ButtonField, you could achieve what you are trying to do.

 

If you want to do it with a standard RIM ButtonField, than I think you are out of luck. 

Developer
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: CustomButton Use all Width

Thanks peter, I'll show you a little better, I'm just trying to do this:

 

CustomButtonField Option1 = new CustomButtonField("Off", 0xFFFFFF,
0xFFFFFF, CustomButtonField.USE_ALL_WIDTH)

 

but it gets an error, saying that the long USE_ALL_WIDTH is not in the constructor CustomButtonField(string, int, int)

 

whereas a buttonfield will let me do this:

 

ButtonField Option2 = new ButtonField("Inactive",
ButtonField.USE_ALL_WIDTH) 

 

and this is acceptable. I was just wondering why this is and how to go about an alternative. Thanks for your info though, I appreciated the link and your time.


Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: CustomButton Use all Width

[ Edited ]

If it is your custom button field then you need to place a input value for the long to be accepted. The error you are getting is telling you the issue. Your constructor is expecting a string and two ints but you are passing a string two ints and a long. You need to make a new constructor that will accept the values you are trying to pass to it.

 

ie.

public class CustomButtonField {

   public CustomButtonField(String txt, int width, int height, long style){
      ..........
   }

   ............

}