BlackBerry - ButtonField com Bitmap centralizado

Eu tenho uma classe que se estende de ButtonField:

class BitmapButtonField extends ButtonField
{
    private Bitmap _bitmap;
    private int _buttonWidth;
    private int _buttonHeight;

    BitmapButtonField(Bitmap bitmap, int buttonWidth, int buttonHeight, long style) 
    {    
        super(style);
        _buttonWidth = buttonWidth;
        _buttonHeight = buttonHeight;
        _bitmap = bitmap;
    }

    public int getPreferredHeight() 
    {
        return _buttonHeight;
    }

    public int getPreferredWidth() 
    {
        return _buttonWidth;
    }

    protected void layout(int width, int height) 
    {
        setExtent(Math.min( width, getPreferredWidth()), Math.min( height, getPreferredHeight()));
    }

    protected void paint(Graphics graphics) 
    {       
        // THIS IS NOT CENTERED
        int x = (getPreferredWidth() - _bitmap.getWidth()) >> 1;
        graphics.drawBitmap(x, 0, _bitmap.getWidth(), _bitmap.getHeight(), _bitmap, 0, 0);

        // THIS IS NOT LEFTMOST, TOPMOST
        graphics.drawBitmap(0, 0, _bitmap.getWidth(), _bitmap.getHeight(), _bitmap, 0, 0);
    }
} 

Se você pudesse ver pelos meus comentários sobre o método de pintura, claramente a posição ButtonField 0,0 não está exatamente no canto mais à esquerda e superior do botão, de alguma forma ele é preenchido com offset desconhecido, então isso torna a centralização da imagem difícil.

Mas se eu estender de uma classe Field, o problema desaparece, mas eu preciso continuar estendendo de ButtonField desde que eu preciso da borda ButtonField e estilo de foco (retângulo arredondado azul-branco), eu só preciso exibir imagem centralizada em um ButtonField, e ainda mantendo todos os atributos padrão do ButtonField.

Existe uma maneira de eliminar o deslocamento acolchoado no método de pintura em um ButtonField? Eu tentei setPadding e setMargin mas sem essa sorte. Muito obrigado!

questionAnswers(1)

yourAnswerToTheQuestion