Drawing and positioning images

Your BlackBerry® device application can use Graphics objects to perform drawing functions and rendering operations. Use the Graphics class to draw over the entire screen or on a Field. If your application does not contain any fields, override the javax.microedition.lcdui.Canvas.paint(Graphics) method to perform the painting using the specified Graphics object.

To draw in a specific Bitmap, a BlackBerry device application obtains a graphics context by passing the Bitmap object into the Graphics constructor. To draw over a Bitmap without changing the content of the Bitmap, create a BitmapField and pass the Bitmap object into the BitmapField constructor. When drawing in a field, the field's manager passes a graphics context to the fields when the fields repaint. To perform custom drawing in a field, override the paint(Graphics g) method when you extend the Field class. The Graphics class enables you to draw shapes, such as arcs, lines, rectangles, and circles.

Next topic: Position an image

Was this information helpful? Send us your comments.