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
Contributor
Posts: 34
Registered: ‎10-03-2012
My Device: 9300
My Carrier: cell c

Graphics Navigation

Hi

Iam trying to get navigation events in a graphics context.

here is a simple code to illustrate what iam trying to do. i want to paint a blue rectangle when the user click the navigation button.Thank you in advance

 

package

mypackage;

 

 

import

net.rim.device.api.ui.Graphics;

import

net.rim.device.api.ui.Field;

 

 

 

public

class Dball extendsField{

 

 

Graphics

f;

 

protectedvoid layout(int width, intheight) {

setExtent

(Math.min(width, getPreferredWidth()), Math.min(height,

getPreferredHeight()));

}

publicintgetPreferredHeight() {

 

return288;

}

publicintgetPreferredWidth() {

 

return288;

}

protectedvoidpaint(Graphics g)

{

intwidth = getWidth();

 

intheight = getHeight();

 

 

g.setColor(0x708090);

g.fillRect(0, 0, width, height);

 

 

g.setColor(0xff0000);

g.fillRect(100, 100, 50, 50);

 

}

protected boolean navigationClick(int status, inttime) {

 

f.setColor(0x0000ff);

 

f.fillRect(100, 100, 50, 50);

 

return true;

}

 

 

}

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Graphics Navigation

[ Edited ]

The usual way to do this is to set a 'state' indicating how you want the Field painted, then invalidate() the Field.  Then override paint to check the 'state' and paint accordingly.  Invalidate() will cause the Field to be repainted. 

 

As far as I am aware, there is no supported direct way to paint into the visible screen buffer.