Hey, for you to get basic knowledge about the j2me I am giving you code below which will print the hello world, So use to to know more about the j2me. The code below will Print "Hello World" in a Mobile Phone Using J2ME. You can see the output with the help of simulator.
Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorld extends MIDlet implements CommandListener
{
private Command cmd;
private TextBox t1;
public HelloWorld()
{
cmd = new Command("Exit", Command.EXIT, 1);
t1 = new TextBox("Hello world MIDlet", "Hello World!", 25, 0);
t1.addCommand(exitCommand);
t1.setCommandListener(this);
}
protected void startApp()
{
Display.getDisplay(this).setCurrent(t1);
}
protected void pauseApp() {}
protected void destroyApp(boolean bool)
{
}
public void commandAction(Command cmd1, Displayable disp)
{
if (cmd1 == cmd)
{
destroyApp(false);
notifyDestroyed();
}
}
}
Bookmarks