WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章J2ME技术程序开发基于MIDP1.0实现RMS容量探测器

基于MIDP1.0实现RMS容量探测器
作者:詹建飞  来源:J2MEDV  发布时间:2005-9-7 13:09:05
tTimeout(2500);
display.setCurrent(alert);

}

}

import java.util.Timer;
import java.util.TimerTask;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.rms.*;

public class CounterCanvas extends Canvas implements CommandListener
{

private RMSModel model;
private RMSAnalyzer RMSanalyzer;
private int interTime;
private int counter;
private boolean go = true;
public static Command exitCommand = new Command("退出", Command.EXIT, 3);
public static final int INC = 1;
public TimerTask timerTask;
public final Timer timer = new Timer();

public CounterCanvas(int interTime, int base, RMSAnalyzer rmsa)
throws RecordStoreException
{
this.interTime = interTime;
this.counter = base;
this.RMSanalyzer = rmsa;
model = new RMSModel(base, RMSanalyzer);
this.addCommand(exitCommand);
this.setCommandListener(this);

timerTask = new TimerTask()
{
public void run()
{

try
{
model.writeRecord(INC);
counter++;
} catch (RecordStoreFullException e)
{
go = false;
model.deleteRMS();
timer.cancel();
} catch (RecordStoreException e)
{
model.deleteRMS();
RMSanalyzer.showAlertError(e.getMessage());
timer.cancel();
}
repaint();

}
};

}

public void start()
{
timer.schedule(timerTask, 500, interTime);
}

public void setCounter(int counter)
{
this.counter = counter;
}

public void setInterTime(int interTime)
{
this.interTime = interTime;
}


protected void paint(Graphics arg0)
{

int SCREEN_WIDTH = this.getWidth();
int SCREEN_HEIGHT = this.getHeight();
arg0.drawRect(SCREEN_WIDTH / 10, SCREEN_HEIGHT / 2,
SCREEN_WIDTH * 4 / 5, 10);
if (RMSanalyzer.getDisplay().isColor())
{
arg0.setColor(128, 128, 255);
}
arg0.fillRect(SCREEN_WIDTH / 10 + 1, SCREEN_HEIGHT / 2 + 1, counter, 9);
if (!go)
arg0.drawString("最大值:" + counter + "K字节", SCREEN_WIDTH / 10,
SCREEN_HEIGHT / 10, Graphics.TOP | Graphics.LEFT);

}

public void commandAction(Command arg0, Displayable arg1)
{

if (arg0 == exitCommand)
{
RMSanalyzer.exitMIDlet();
}

}

}
RMSAnalyzer.jad
MIDlet-Jar-Size: 15785
MIDlet-1: RMSAnalyzer,,RMSAnalyzer
MIDlet-Jar-URL: RMSAnalyzer.jar
MicroEdition-Configuration: CLDC-1.0
MIDlet-Version: 1.0.0
MIDlet-Name: RMSAnalyzer
MIDlet-Data-Size: 8192
MicroEdition-Profile: MIDP-1.0
INTER: 100

上一页  [1] [2] 

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码