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

Posts: 88
Registered: ‎05-24-2009
My Device: Not Specified
Accepted Solution

Empty Field - Take up some space



I was wondering how to make an empty field to take up some space. Say i want another field to be 50 pixels down from the top. I need a field to take up the 50 pixels at the top that do nothing. Basically i need a field that i can set a size of ( both vertical and horizontal). Any core fields have that capability, or do i need to write a custom one?



Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Empty Field - Take up some space

I'm afraid you'll have to make your own.  Something along the lines of:


class EmptyField extends Field {
    int _width;
    int _height;

    public EmptyField(int width, int height) {
        _width = width;
        _height = height;

    public EmptyField(int width, int height, long style) {
        _width = width;
        _height = height;

    protected void layout(int w, int h) {
        int actWidth = Math.min(_width, w);
        int actHeight = Math.min(_height, h);
        setExtent(actWidth, actHeight);

    protected void paint(Graphics g) {
        // nothing to do

    public int getPreferredWidth() {
        return _width;

    public int getPreferredHeight() {
        return _height;





please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Posts: 35
Registered: ‎09-15-2011
My Device: Torch 9800, Tour 9630
My Carrier: VZW

Re: Empty Field - Take up some space

Shorter solution.


Field emptyField = new Field(){
    protected void layout(int width, int height){
        setExtent(myWidth, myHeight);
    protected void paint(Graphics graphics){}