- 浏览: 30205 次
- 性别:
- 来自: 北京
-
最新评论
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.ChoiceGroup;
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.Gauge;
import javax.microedition.midlet.MIDlet;
public class AlertDemo extends MIDlet {
private Display display;
private static final Command CMD_EXIT = new Command("Exit",Command.EXIT,1);
private static final Command CMD_SHOW = new Command("Show",Command.SCREEN,1);
private Form mainForm;
private final static int SECOND = 1000;
private static final String[] typeStrings = {
"Alarm","Confirmation","Error","Info","Warning"
};
private final static String[] timeoutStrings = {
"2 Seconds","4 Seconds","8 Seconds","Forever"
};
private boolean firstTime;
public AlertDemo(){
firstTime = true;
mainForm = new Form("Alert Options");
}
protected void startApp() {
display = Display.getDisplay(this);
showOption();
}
private void showOption(){
if(firstTime){
ChoiceGroup types = new ChoiceGroup("Type",ChoiceGroup.POPUP,typeStrings,null);
mainForm.append(types);
ChoiceGroup timeouts = new ChoiceGroup("Timeout",ChoiceGroup.POPUP,timeoutStrings,null);
mainForm.append(timeouts);
String[] optionStrings = {"Show Indicator"};
ChoiceGroup options = new ChoiceGroup("Options",ChoiceGroup.MULTIPLE,optionStrings,null);
mainForm.append(options);
mainForm.addCommand(CMD_SHOW);
mainForm.addCommand(CMD_EXIT);
mainForm.setCommandListener(new AlerListener(types,timeouts,options));
firstTime = false;
}
display.setCurrent(mainForm);
}
private class AlerListener implements CommandListener {
AlertType[] alertTypes = {
AlertType.ALARM,AlertType.CONFIRMATION,AlertType.ERROR,AlertType.INFO,AlertType.WARNING
};
ChoiceGroup typesCG;
ChoiceGroup timeoutsCG;
ChoiceGroup indicatorCG;
int[] timeouts = {2*SECOND,4*SECOND,8*SECOND,Alert.FOREVER};
public AlerListener(ChoiceGroup types,ChoiceGroup timouts,ChoiceGroup indicator){
typesCG = types;
timeoutsCG = timouts;
indicatorCG = indicator;
}
public void commandAction(Command c, Displayable d) {
if(c == CMD_SHOW){
Alert alert = new Alert("Alert");
int typeIndex = typesCG.getSelectedIndex();
alert.setType(alertTypes[typeIndex]);
int timeoutIndex = timeoutsCG.getSelectedIndex();
alert.setTimeout(timeouts[timeoutIndex]);
alert.setString(typeStrings[typeIndex] + " Alert, Running "
+ timeoutStrings[timeoutIndex]);
boolean[] selectFlags = new boolean[1];
indicatorCG.getSelectedFlags(selectFlags);
if(selectFlags[0]){
Gauge indicator = createIndicator(timeouts[timeoutIndex]);
alert.setIndicator(indicator);
}
display.setCurrent(alert);
}else if(c == CMD_EXIT){
destroyApp(false);
notifyDestroyed();
}
}
}
protected void destroyApp(boolean arg0) {
}
protected void pauseApp() {
}
public Gauge createIndicator(int maxValue){
if(maxValue == Alert.FOREVER){
return new Gauge(null,false,Gauge.INDEFINITE,Gauge.CONTINUOUS_RUNNING);
}
final int max = maxValue / SECOND;
final Gauge indicator = new Gauge(null,false,max,0);
new Thread(){
public void run(){
int value = 0;
while (value < max){
indicator.setValue(value);
++value;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}.start();
return indicator;
}
}
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.ChoiceGroup;
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.Gauge;
import javax.microedition.midlet.MIDlet;
public class AlertDemo extends MIDlet {
private Display display;
private static final Command CMD_EXIT = new Command("Exit",Command.EXIT,1);
private static final Command CMD_SHOW = new Command("Show",Command.SCREEN,1);
private Form mainForm;
private final static int SECOND = 1000;
private static final String[] typeStrings = {
"Alarm","Confirmation","Error","Info","Warning"
};
private final static String[] timeoutStrings = {
"2 Seconds","4 Seconds","8 Seconds","Forever"
};
private boolean firstTime;
public AlertDemo(){
firstTime = true;
mainForm = new Form("Alert Options");
}
protected void startApp() {
display = Display.getDisplay(this);
showOption();
}
private void showOption(){
if(firstTime){
ChoiceGroup types = new ChoiceGroup("Type",ChoiceGroup.POPUP,typeStrings,null);
mainForm.append(types);
ChoiceGroup timeouts = new ChoiceGroup("Timeout",ChoiceGroup.POPUP,timeoutStrings,null);
mainForm.append(timeouts);
String[] optionStrings = {"Show Indicator"};
ChoiceGroup options = new ChoiceGroup("Options",ChoiceGroup.MULTIPLE,optionStrings,null);
mainForm.append(options);
mainForm.addCommand(CMD_SHOW);
mainForm.addCommand(CMD_EXIT);
mainForm.setCommandListener(new AlerListener(types,timeouts,options));
firstTime = false;
}
display.setCurrent(mainForm);
}
private class AlerListener implements CommandListener {
AlertType[] alertTypes = {
AlertType.ALARM,AlertType.CONFIRMATION,AlertType.ERROR,AlertType.INFO,AlertType.WARNING
};
ChoiceGroup typesCG;
ChoiceGroup timeoutsCG;
ChoiceGroup indicatorCG;
int[] timeouts = {2*SECOND,4*SECOND,8*SECOND,Alert.FOREVER};
public AlerListener(ChoiceGroup types,ChoiceGroup timouts,ChoiceGroup indicator){
typesCG = types;
timeoutsCG = timouts;
indicatorCG = indicator;
}
public void commandAction(Command c, Displayable d) {
if(c == CMD_SHOW){
Alert alert = new Alert("Alert");
int typeIndex = typesCG.getSelectedIndex();
alert.setType(alertTypes[typeIndex]);
int timeoutIndex = timeoutsCG.getSelectedIndex();
alert.setTimeout(timeouts[timeoutIndex]);
alert.setString(typeStrings[typeIndex] + " Alert, Running "
+ timeoutStrings[timeoutIndex]);
boolean[] selectFlags = new boolean[1];
indicatorCG.getSelectedFlags(selectFlags);
if(selectFlags[0]){
Gauge indicator = createIndicator(timeouts[timeoutIndex]);
alert.setIndicator(indicator);
}
display.setCurrent(alert);
}else if(c == CMD_EXIT){
destroyApp(false);
notifyDestroyed();
}
}
}
protected void destroyApp(boolean arg0) {
}
protected void pauseApp() {
}
public Gauge createIndicator(int maxValue){
if(maxValue == Alert.FOREVER){
return new Gauge(null,false,Gauge.INDEFINITE,Gauge.CONTINUOUS_RUNNING);
}
final int max = maxValue / SECOND;
final Gauge indicator = new Gauge(null,false,max,0);
new Thread(){
public void run(){
int value = 0;
while (value < max){
indicator.setValue(value);
++value;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}.start();
return indicator;
}
}
发表评论
-
开发高可移植性J2ME的软件
2010-03-04 15:59 1272随着MTK的流行,使现在 ... -
J2ME 颜色渐变
2010-01-31 16:23 974import javax.microedition.lcdui ... -
J2ME断点下载文件
2010-01-31 16:21 1871package downfile; import java. ... -
J2ME连接WAP网
2010-01-25 21:11 1456网上有好多J2ME联网的例子,但是我发现基本能搜到的都不适用, ... -
j2me中对时间处理的方法 TextFieldWithItemStateListenerMIDlet.java
2010-01-22 12:43 1072import java.util.Calendar; impo ... -
ContextConnection的子类FileConnection,HttpConnection
2010-01-20 19:40 995FileConnection fc = null; ... -
图片元素开发 ImageItemDemo.java
2010-01-20 18:38 796import java.io.IOException; im ... -
字符元素开发 StringItemDemo.java
2010-01-20 18:37 978import java.io.IOException; im ... -
j2me的TextBox开发 TextBoxDemo.java
2010-01-20 18:35 1186import javax.microedition.lcdui ... -
j2me的List列表开发 ListDemo.java
2010-01-20 18:34 1598import java.io.IOException; im ... -
对用户的错误进行预警的第二种写法
2010-01-20 18:33 864import javax.microedition.lcdui ... -
使用HTTP协议发送和接受文本数据 SampleClient.java
2010-01-20 18:23 1547import java.io.ByteArrayOutputS ... -
HttpConnectionHelper.java
2010-01-20 18:22 814import java.io.*; import java ...
相关推荐
5. **main.java和README.txt** 在提供的文件列表中,`main.java`可能包含了上述的Java Swing或JavaFX示例代码,或者是一个用于调用JavaScript的JSP页面。而`README.txt`通常是项目的说明文件,可能包含了如何运行或...
在iOS开发中,创建一个带有多个视图的iPhone应用程序是一个常见的需求,这通常涉及到界面的交互性和用户体验的设计。本教程将深入讲解如何在iPhone应用中使用工具栏(Toolbar)来实现简单的多视图切换,这对于初学者...
内容概要:本文详细介绍了LabVIEW控件的设计与实现,尤其是一些由经验丰富的老工程师精心打造的控件。LabVIEW是一款图形化编程语言,广泛应用于数据采集、仪器控制和工业自动化领域。文中通过具体实例展示了如何利用LabVIEW创建美观且功能强大的控件,如滑动条、波形图、金属质感旋钮、动态波形图表以及智能选项卡等。作者强调了LabVIEW控件在灵活性和美观度方面的优势,并分享了许多实用的技术细节和优化方法。 适合人群:具有一定编程基础并希望深入了解LabVIEW控件设计的开发者和技术爱好者。 使用场景及目标:适用于需要进行高效的数据展示和交互设计的应用场景,如工业控制系统、实验室设备操作界面等。目标是帮助用户掌握LabVIEW控件的高级特性,提高开发效率和用户体验。 其他说明:文章不仅提供了具体的代码示例,还探讨了控件美学背后的设计理念和技术实现,鼓励读者探索更多可能性。
Delphi 12.3控件之unidac_10.4.0_d27pro.exe
11.盛趣自闭面(还是自己太菜).txt
58面经面试过程和题目.txt
电大操作系统课后习题解答
人工智能技术与应用演讲【61页PPT】
chromedriver-mac-arm64-135.0.7049.41.zip
内容概要:本文详细介绍了QPSK(四相移键控)调制方法及其在瑞利信道和高斯白噪声信道下的误码率(BER)性能分析。首先展示了QPSK星座图的绘制方法,接着构建了一个简化的QPSK发射机模型,用于将二进制比特流映射到相应的星座点。随后,分别实现了两种信道模型:高斯白噪声信道(AWGN)和瑞利信道,并解释了它们的工作原理以及如何向传输信号添加噪声。文中还提供了详细的误码率测试脚本,通过大量随机比特进行仿真,最终得到了不同信噪比条件下的误码率曲线。此外,作者还讨论了QPSK与其他调制方式如BPSK、16QAM之间的性能差异,强调了频谱效率与抗噪能力之间的权衡关系。 适合人群:对无线通信系统感兴趣的科研人员、研究生以及从事通信工程领域的工程师。 使用场景及目标:①帮助读者理解QPSK的基本原理及其在不同信道环境中的行为特性;②提供实用的Python代码片段,便于快速搭建仿真环境并验证理论结果;③探讨各种调制方式的选择依据,指导实际应用中的优化决策。 其他说明:文中多次提到‘骚操作’,意指一些巧妙但非传统的编程技巧,有助于提高代码执行效率或简化复杂度。同时提醒读者注意仿真过程中可能出现的问题,如
新建 Microsoft Word 文档 (9).docx
计算机科学与技术- 软件开发工具 培训资料
bitcount统计每个元素中设置的位数 B = bitcount(A) Counts the number '1' bits in each element B = bitcount(A, bitValue) "bitValue" = 1 = default = counts the occurance of '1' if bitValue = 0; counts the number '0' The total bits to verify is [8,16,32,or 64] based on the maximal value of A B = bitcount(A, bitValue, maxBits) the total # of bits to examine
MOM生产运营管理平台解决方案【35页PPT】
deli-数码录音电话机-HCD6238(28)P-TSD-使用说明书
Java项目基于ssm框架的课程设计,包含LW+ppt
Delphi 12.3控件之Tsilang 7.5.0.0 D12.7z
ios+UIButton分类+UIButton+UIButton图片文字位置
项目已获导师指导并通过的高分毕业设计项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载
Java项目基于ssm框架的课程设计,包含LW+ppt