I attempted to write my own code based on the tutorial book and the sample code. The error that I had was due to defining a string longer than the length defined. The other warning message that I got was with regard to using the default Hello World Class which I ignored. However, I am not sure as to why I got the message and whether what I did was right. The screen shot of the emulator is above. The code is as follows:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorld extends MIDlet implements CommandListener {
private Command exitCommand;
private TextBox tbox;
public HelloWorld() {
exitCommand = new Command("Exit", Command.EXIT, 1);
tbox = new TextBox("Hello world MIDlet", "Welcome to Riddhima's World!", 50, 0);
tbox.addCommand(exitCommand);
tbox.setCommandListener(this);
}
protected void startApp() {
Display.getDisplay(this).setCurrent(tbox);
}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
public void commandAction(Command cmd, Displayable disp) {
if (cmd == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
No comments:
Post a Comment