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
New Developer
Posts: 13
Registered: ‎09-15-2009
My Device: Not Specified
Accepted Solution

ButtonField and USE_ALL_HEIGHT / USE_ALL_WIDTH

Am I right in thinking that ButtonField doesn't pay attention to USE_ALL_HEIGHT or USE_ALL_WIDTH?

 

I'd like to subclass ButtonField so that it uses these style bits, and currently I'm overriding layout per below. Does this seem like the right way to go? It works, but there may be a more clean way to do this.

 

Also, is there any way to get the source of the base components like ButtonField, or do we just have to guess at what they do?

 

 

protected void layout(int width, int height) { super.layout(width, height); long style = this.getStyle(); if ((style & Field.USE_ALL_WIDTH) == Field.USE_ALL_WIDTH) { this.setExtent(width, this.getHeight()); }}

 


 

Highlighted
Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: ButtonField and USE_ALL_HEIGHT / USE_ALL_WIDTH

RIM does not provide their source code open. So there is no way to get their code.

 

You can fix the width and height of a buttonField by overriding layout() method like:

	protected void layout(int width, int height)
{
//width.
width = Display.getWidth();

//height.
height = 20;

//dimensions.
setExtent( width, height );

}

Have a look at this CustonButtonField example:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=37909&query.id=17...

 

Also check the custombuttons sample shipped with the JDE.

 

Regards

Bikas