虽然配置为一组通用设备提供了最小的 java平台,但是应用程序开发者感兴趣的是为一个个别的设备生产应用程序,当他们只是使用配置的话,他们编写的应用程序就会有一些欠缺。
配置必须满足所有的设备的最小的要求, 用户界面、输入机制和数据持久性有高度地设备具体性,每一种设备都有自己的用户界面、输入机制和数据存储方法,这些往往不在配置所满足的最小要求的范围之内。
简表为相同消费电子设备的不同的生产商提供了标准化的 java类库, 事实上,虽然配置规范的开发由 sun领导,但是许多简表规范仍将继续由特殊设备的供应商领导。
比如说, motorola领导了行动电话和呼叫器简表规范的开发,又如 palm 领导 pda简表的开发。
现在,五个已知简表已经有了规范, 记住,每个简表的责任都是为了完善配置的不足,下表列出了这五个简表:
| // 到如需要的j2me类 import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.rms.*; // 扩展midlet类来构建我们的自定义midlet public class fundtracker extends midlet implements commandlistener { file://显示管理者变量 private display display = null; file://midlet的表单变量 private requestform reqform = null; file://midlet构建器 public fundtracker () { display = display.getdisplay(this); reqform = new requestform("fund tracker"); reqform.initform(); reqform.setcommandlistener(this); } file://开始 midlet 应用程序 protected void startapp() { display.setcurrent(reqform); } file://暂停 midlet protected void pauseapp() { } file://销毁midlet protected void destroyapp(boolean unconditional) { } file://通过监听者响应命令 public void commandaction(command c, displayable s) { if (c == reqform.getexitcommand()) { destroyapp(false); notifydestroyed(); return; } if ((c == reqform.getgetcommand()) && (reqform.getsymfield().getstring().length() > 0)) { getanddisplayquote(); } else { reqform.getmsgstring().settext("symbol required"); } } file://储存由#分开的成对的基金字符串和报价字符串 private void storequote (string fund, string newquote) { file://数据库变量 recordstore quotedb = null; try { quotedb = recordstore.openrecordstore( "fundquotes", true); byte[] data = (fund + "#" + newquote).getbytes(); int size = data.length; quotedb.addrecord(data, 0, size); quotedb.closerecordstore(); } catch (exception recordexception) { system.out.println("unable to store quote and/or use fund quote database."); } } file://通过quoteservice类取回提交的代号表示的基金报价 private void getanddisplayquote(){ string fundsymbol = reqform.getsymfield().getstring(); if (fundsymbol.length() > 0) { string thequote = quoteservice.getquote(fundsymbol); if (thequote != null) { storequote(fundsymbol, thequote); reqform.getmsgstring().settext(thequote); } else reqform.getmsgstring().settext("no quote" + '\n' + "check symbol"); } } } |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器