跳到主要內容

發表文章

目前顯示的是有「J2ME」標籤的文章

[J2ME] Hello World

Create a form with "Hello World" and add a Exit Command to exit the process. import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloWorld extends MIDlet implements CommandListener { private Display display; private Command exitCommand; private Form form; public HelloWorld() { display=Display.getDisplay(this); exitCommand = new Command("Exit", Command.EXIT,1); form=new Form("My J2ME Hello World!"); form.append("Welcome to J2ME!"); form.addCommand(exitCommand); form.setCommandListener(this); } protected void destroyApp(boolean arg0) throws MIDletStateChangeException { } protected void pauseApp() { } public void commandAction(Command cmd, Displayable disp) { if (cmd == exitCommand) { try{ destroyApp(false); } catch(MIDletStateChangeException ex ){ System.out.println(ex.getMessage()); ...