1

In my project I need to put a LabelField on top of a BitmapField. I have the BitmapField inside a VerticalFieldManager. I want complete code for this problem.

My application is for BlackBerry OS 4.7.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Dean Jones
  • 11
  • 2

3 Answers3

1

You can create your own class extends BitmapField and override method paintBitmap().

Like this:

public class MyBitmapField extends BitmapField {
//...       
protected void paintBitmap(Graphics g, int arg1, int arg2, int arg3,
        int arg4, Bitmap arg5, int arg6, int arg7) {            
    super.paintBitmap(g, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
    g.drawText("Your text", 5,5 );  
}

// ...

}

Also you can override drawFocus(), paintBackground() and other.

Vlad Tsepelev
  • 2,056
  • 1
  • 21
  • 32
1

Also you could draw text over bitmap:

class Scr extends MainScreen {
    Bitmap bmp = new Bitmap(200, 100);

    public Scr() {
        //draw bitmap
        Graphics g = new Graphics(bmp);
        g.drawLine(0, 0, 199, 99);
        g.drawLine(199, 0, 0, 99);

        //draw text
        Font f = getFont().derive(Font.PLAIN, 15);
        g.drawText("hello", 0, (bmp.getHeight() - f.getHeight()) >> 1, 
            DrawStyle.HCENTER|DrawStyle.VCENTER);
        add(new BitmapField(bmp));
    }
}

Other way is to implement custom layout like in Blackberry - fields layout animation

Community
  • 1
  • 1
Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
0

Or use a negative margin (the source code is available for download at the bottom of that page):

enter image description here

UPDATE: One more link for NegativeMarginVerticalFieldManager

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416