import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Ticker;
import javax.microedition.midlet.MIDlet;
public class HelloWorld extends MIDlet implements CommandListener {
private Form mainForm;
private Command exitCommand;
private Command infoC;
private Command buyC;
private Ticker hi = new Ticker("J2ME is cool"); //滚动条
public void startApp() {
Display display = Display.getDisplay(this);
mainForm = new Form("HelloWorld");
mainForm.append("Welcome to the world of MIDlets!");
exitCommand = new Command("Exit", Command.EXIT, 0);
infoC = new Command("Info", Command.SCREEN, 1);
buyC = new Command("Buy", Command.SCREEN, 2);
mainForm.addCommand(exitCommand);
mainForm.addCommand(infoC);
mainForm.addCommand(buyC);
mainForm.setCommandListener(this);
mainForm.setTicker(hi);
display.setCurrent(mainForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
notifyDestroyed();
}
if (c == infoC) {
mainForm.append("\n fuck");
}
if(c == buyC){
mainForm.append("\n"+mainForm.toString());
}
}
}
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Ticker;
import javax.microedition.midlet.MIDlet;
public class HelloWorld extends MIDlet implements CommandListener {
private Form mainForm;
private Command exitCommand;
private Command infoC;
private Command buyC;
private Ticker hi = new Ticker("J2ME is cool"); //滚动条
public void startApp() {
Display display = Display.getDisplay(this);
mainForm = new Form("HelloWorld");
mainForm.append("Welcome to the world of MIDlets!");
exitCommand = new Command("Exit", Command.EXIT, 0);
infoC = new Command("Info", Command.SCREEN, 1);
buyC = new Command("Buy", Command.SCREEN, 2);
mainForm.addCommand(exitCommand);
mainForm.addCommand(infoC);
mainForm.addCommand(buyC);
mainForm.setCommandListener(this);
mainForm.setTicker(hi);
display.setCurrent(mainForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
notifyDestroyed();
}
if (c == infoC) {
mainForm.append("\n fuck");
}
if(c == buyC){
mainForm.append("\n"+mainForm.toString());
}
}
}