Form frmMain = new Form("系统命令安钮演示");Command cmdscreen1 = new Command("SCREEN1", Command.SCREEN, 1);frmMain.addCommand(cmdScreen1);Display.getDisplay(this).setCurrent(frmMain);这样的句子是不是因为不能显示出来,要如何的句子才可以被显示出来?
补充1 2008-05-20 08:45
对了是J2ME装了WTK模拟器
补充2 2008-05-20 16:27
是运行不显示
您这写的J2ME中高级UI的程序(Procedures).我给一个我写的J2ME测试程序(Procedures)给您看看./***Midlet.java***/package com.test;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;import com.test.controller.UIManager;/** * * @author DaiBen * */public class Milet extends MIDlet{Display dis;UIManager controller ;public Milet(){super();dis = Display.getDisplay(this);}protected void destroyApp(boolean arg0) throws MIDletStateChangeException{}protected void pauseApp(){this.notifyPaused();}protected void startApp() throws MIDletStateChangeException{UIManager controller = new UIManager(this);controller.init();}public void exit(boolean args){try{destroyApp(args);notifyDestroyed();} catch (MIDletStateChangeException e){e.printStackTrace();}}public void setCurrent(Displayable displayable){dis.setCurrent(displayable);}}/**UIManager.java**//** * * *类名称:UIManager *类说明: * MVC中的控制器部分,负责界面事件的处理,以及决定该显示哪一个UI. *@author DaiBen */package com.test.controller;import javax.microedition.lcdui.Displayable;import com.test.Milet;import com.test.gui.Client;import com.test.gui.RMS;import com.test.gui.Server;import com.test.gui.Welcome;public class UIManager{private Milet midlet;private Server server;private Client client;private Welcome index;private RMS rms;public UIManager(Milet midlet){this.midlet = midlet;}public void init(){index = new Welcome(this);setCurrent(index);}public void setCurrent(Displayable disp){midlet.setCurrent(disp);}public static class EventID{private EventID(){}public static final byte EVENT_EXIT = 0;// 退出public static final byte EVENT_CLINET = 1;// Socket客户端public static final byte EVENT_SERVER = 2;// Socket服务器(Server)public static final byte EVENT_RMS = 3;// RMS}public void handleEvent(int eventID, Object[] args){switch (eventID){case EventID.EVENT_EXIT:midlet.exit(true);break;case EventID.EVENT_CLINET:client = new Client(this);setCurrent(client);break;case EventID.EVENT_SERVER:server = new Server(this);setCurrent(server);break;case EventID.EVENT_RMS:rms = new RMS(this);setCurrent(rms);break;default:break;}}}/*Welcome.java**/package com.test.gui;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Form;import com.test.controller.UIManager;/** * * @author DaiBen * */public class Welcome extends Form implements CommandListener{Command cmdExit = new Command("退出", Command.EXIT, 0);Command cmdClient = new Command("客户端", Command.ITEM, 1);Command cmdServer = new Command("服务器(Server)", Command.ITEM, 2);Command cmdRMS = new Command("RMS", Command.SCREEN, 3);UIManager controller;public Welcome(UIManager _controller){super("J2ME测试程序(Procedures)");this.addCommand(cmdExit);this.addCommand(cmdClient);this.addCommand(cmdServer);this.addCommand(cmdRMS);this.setCommandListener(this);this.controller = _controller;}public void commandAction(Command c, Displayable d){if (c == cmdExit){controller.handleEvent(UIManager.EventID.EVENT_EXIT, null);}if (c == cmdServer){controller.handleEvent(UIManager.EventID.EVENT_SERVER, null);}if (c == cmdClient){controller.handleEvent(UIManager.EventID.EVENT_CLINET, null);}if (c == cmdRMS){controller.handleEvent(UIManager.EventID.EVENT_RMS, null);}}}
J2me的东西您写的没问题但是不明白您说的显示是什么样的意思?您没装WTK?