Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   I am having trouble completing the following code in threads. (http://www.go4expert.com/forums/i-trouble-completing-following-code-t9681/)

n.desai 2Apr2008 00:00

I am having trouble completing the following code in threads.
 
Code:

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;


public class GaugeDemo extends MIDlet implements CommandListener {
    private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
    private Display display;
    private NonInteractiveGaugeRunnable nonInteractive;
    private Form mainForm;

    public GaugeDemo() {
        display = Display.getDisplay(this);
        mainForm = new Form("Gauge Demo");
        nonInteractive = new NonInteractiveGaugeRunnable("Non Interactive", 10, 0);
        new Thread(nonInteractive).start();
        mainForm.append(nonInteractive);
        mainForm.addCommand(CMD_EXIT);
        mainForm.setCommandListener(this);
    }


    protected void startApp() {
        display.setCurrent(mainForm);
    }

    protected void destroyApp(boolean unconditional) {
        nonInteractive.setDone();
    }

    protected void pauseApp() {
    }

    public void commandAction(Command c, Displayable d) {
        destroyApp(false);
        notifyDestroyed();
    }
}

and one more canvas class

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;


public class GaugeDemo extends MIDlet implements CommandListener {
    private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
    private Display display;
    private NonInteractiveGaugeRunnable nonInteractive;
    private Form mainForm;

    public GaugeDemo() {
        display = Display.getDisplay(this);
        mainForm = new Form("Gauge Demo");
        nonInteractive = new NonInteractiveGaugeRunnable("Non Interactive", 10, 0);
        new Thread(nonInteractive).start();
        mainForm.append(nonInteractive);
        mainForm.addCommand(CMD_EXIT);
        mainForm.setCommandListener(this);
    }


    protected void startApp() {
        display.setCurrent(mainForm);
    }

    protected void destroyApp(boolean unconditional) {
        nonInteractive.setDone();
    }

    protected void pauseApp() {
    }

    public void commandAction(Command c, Displayable d) {
        destroyApp(false);
        notifyDestroyed();
    }
}

Could some one help me please.


All times are GMT +5.5. The time now is 03:27.