tags:

views:

160

answers:

1

My app extends the ui.Manager class. Is it possible to enter the app without using the enterEventDispatcher. As it needs me to inherit the Application/UiApplication to do that.

Is multiple inheritance the solution? "Which is rather not possible in Java". So is it about using interfaces?

Pls show me d way Gawd Im confused.

+3  A: 

You should really inherit App from UiApplication (if it has some UI) or from Application (if it's background app, service).
If you have some Manager extension, place it into Screen extension. Like this:

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;

public class CenterButtonPanelApp extends UiApplication {

    public CenterButtonPanelApp() {
     pushScreen(new Scr());
    }

    public static void main(String[] args) {
     CenterButtonPanelApp app = new CenterButtonPanelApp();
     app.enterEventDispatcher();
    }
}

class Scr extends MainScreen {
    public Scr() {
     CenterButtonPanel centerPanel = new CenterButtonPanel();
     add(centerPanel);
    }
}

class CenterButtonPanel extends HorizontalFieldManager {
    int mWidth = Display.getWidth();

    public CenterButtonPanel() {
     super(FIELD_HCENTER);
    }

    public int getPreferredWidth() {
     return mWidth;
    }

    protected void sublayout(int maxWidth, int maxHeight) {
     super.sublayout(mWidth, maxHeight);
     setExtent(mWidth, maxHeight);
    }
}
Max Gontar