O.k. My Main class extends midlet, and looks something like this:
Code:
public class SMain extends MIDlet {
private final MFrame frame = SConstants.FRAME;
public final static int ID_MAIN = 0;
....
public static MDataBean currBean=null;
protected void startApp() throws MIDletStateChangeException {
if (frame == null || Display.getDisplay(this).getCurrent() == null) {
init() ;
}else {
frame.getCurrentPanel().doFullRepaint = true;
frame.getCurrentPanel().repaint() ;
}
}
public void init(){
AppEnvironment env = SConstants.EN;
SFactoryListPanel mainMenu = new SFactoryListPanel("Main Menu",SConstants.SIMPLE_LIST, false,true);
mainMenu.addCommand(SConstants.exitCommand);
mainMenu.addCommand(SConstants.selectCommand);
....
frame.addPanel(mainMenu, ID_MAIN);
....
SPanelMediator mediator = new SPanelMediator(this, frame);
// MFrame_BlackBerry extends Canvas.
Display.getDisplay(this).setCurrent((MFrame_BlackBerry)frame);
....
} MFrame_BlackBerry extends Canvas, and acts like this:
Code:
public class MFrame_BlackBerry extends Canvas implements MFrame, TrackwheelListener{
protected Hashtable panels;
protected MPanel currentPanel;
protected int currentPanelID = -1;
private Command[] myCommands = new Command[2];
/** Creates a new instance of MFrame */
public MFrame_BlackBerry(){
Application.getApplication().addTrackwheelListener(this);
MPanel.setDimensions(getWidth(), getHeight(), 0);
panels = new Hashtable();
setCommandListener(this);
}
....
public void paint(Graphics g){
if(currentPanel == null) return ;
currentPanel.paintPanel(g);
}
} Now the currentPanel is of type MPanel, and its paintPanel(g) method is described below:
Code:
public void paintPanel(Graphics g){
g.setClip(0, 0, getWidth(), getHeight());
isShowing = true;
if(doFullRepaint){
paintBackgound(g, 0, 0, getWidth(), getHeight());
paint(g);
} else if(components.contains(repaintComponent) && repaintComponent != null){
paintBackgound(g, repaintComponent.getX(), repaintComponent.getY(),
repaintComponent.getWidth(), repaintComponent.getHeight());
}
int numComp = components.size();
for(int i = 0; i < numComp; i++){
MComponent component = (MComponent)components.elementAt(i);
if((doFullRepaint || repaintComponent == component) && focusComponent != component){
component.paintComponent(g);
}
}
if (focusComponent != null) {
focusComponent.paintComponent(g);
}
g.setClip(0, 0, getWidth(), getHeight());
doFullRepaint = false;
} Now its worth noting that the Display is fine on any normal mobile phone, without any of the implemented trackwheellistener stuff, so I suspect the problem lies in the MFrame_BlackBerry paint() method.
Regards,
Tig*