- 浏览: 30125 次
- 性别:
- 来自: 北京
-
最新评论
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 1266随着MTK的流行,使现在 ... -
J2ME 颜色渐变
2010-01-31 16:23 970import javax.microedition.lcdui ... -
J2ME断点下载文件
2010-01-31 16:21 1867package downfile; import java. ... -
J2ME连接WAP网
2010-01-25 21:11 1448网上有好多J2ME联网的例子,但是我发现基本能搜到的都不适用, ... -
j2me中对时间处理的方法 TextFieldWithItemStateListenerMIDlet.java
2010-01-22 12:43 1064import java.util.Calendar; impo ... -
ContextConnection的子类FileConnection,HttpConnection
2010-01-20 19:40 993FileConnection fc = null; ... -
图片元素开发 ImageItemDemo.java
2010-01-20 18:38 793import java.io.IOException; im ... -
字符元素开发 StringItemDemo.java
2010-01-20 18:37 973import java.io.IOException; im ... -
j2me的TextBox开发 TextBoxDemo.java
2010-01-20 18:35 1175import javax.microedition.lcdui ... -
j2me的List列表开发 ListDemo.java
2010-01-20 18:34 1593import java.io.IOException; im ... -
对用户的错误进行预警的第二种写法
2010-01-20 18:33 860import javax.microedition.lcdui ... -
使用HTTP协议发送和接受文本数据 SampleClient.java
2010-01-20 18:23 1544import java.io.ByteArrayOutputS ... -
HttpConnectionHelper.java
2010-01-20 18:22 808import java.io.*; import java ...
相关推荐
5. **main.java和README.txt** 在提供的文件列表中,`main.java`可能包含了上述的Java Swing或JavaFX示例代码,或者是一个用于调用JavaScript的JSP页面。而`README.txt`通常是项目的说明文件,可能包含了如何运行或...
在iOS开发中,创建一个带有多个视图的iPhone应用程序是一个常见的需求,这通常涉及到界面的交互性和用户体验的设计。本教程将深入讲解如何在iPhone应用中使用工具栏(Toolbar)来实现简单的多视图切换,这对于初学者...
c语言学习
人脸识别项目源码实战
人脸识别项目源码实战
本图书进销存管理系统管理员功能有个人中心,用户管理,图书类型管理,进货订单管理,商品退货管理,批销订单管理,图书信息管理,客户信息管理,供应商管理,库存分析管理,收入金额管理,应收金额管理,我的收藏管理。 用户功能有个人中心,图书类型管理,进货订单管理,商品退货管理,批销订单管理,图书信息管理,客户信息管理,供应商管理,库存分析管理,收入金额管理,应收金额管理。因而具有一定的实用性。 本站是一个B/S模式系统,采用Spring Boot框架,MYSQL数据库设计开发,充分保证系统的稳定性。系统具有界面清晰、操作简单,功能齐全的特点,使得图书进销存管理系统管理工作系统化、规范化。本系统的使用使管理人员从繁重的工作中解脱出来,实现无纸化办公,能够有效的提高图书进销存管理系统管理效率。 关键词:图书进销存管理系统;Spring Boot框架;MYSQL数据库
基于动态规划和模型预测控制的并联混合电动汽车最佳控制 简介:利用动态规划,使用模型预测控制,实现对并联混合动力电动汽车的最佳控制,并降低总体成本函数 使用动态规划可以实现混合动力电动汽车的优化控制 混合动力电动汽车的模型预测控制是通过使用动态规划在缩短的时域内实现的 代码为纯matlab脚本,附带说明电子文档 ,并联混合电动汽车; 动态规划; 模型预测控制; 最佳控制; 总体成本函数; Matlab脚本。,动态规划与模型预测控制在并联混合动力电动汽车的最优控制策略
人脸识别项目实战
2025 DeepSeek技术全景解析-重塑全球AI生态的中国力量.pdf
能够爬取非会员视频和音频资源,可通过ffmpeg等工具将视频资源和音频资源合并
基于差分进化算法DE的机器人路径规划 本产品基于优化的差分进化算法,专为机器人山地路径规划而设计 通过模拟差分进化过程中的变异、交叉与选择机制,算法能够智能探索并确定最优行进路线,全面考量路径长度、能量消耗及地形适应性 优化之处在于融合了动态差分权重与精英保留策略,显著增强了算法的搜索效率和求解质量,有效规避了早熟收敛的风险 该算法在山地这一复杂且多变的自然环境中展现出卓越性能,完美适配于机器人探险、山地救援、环境监测等多种应用场景 我们矢志为用户提供卓越、稳健的机器人路径规划方案,推动各类山地作业迈向更为精确与高效的路径规划新时代 ,差分进化算法DE; 机器人路径规划; 山地路径规划; 算法优化; 早熟收敛风险规避; 山地探险应用场景; 环境监测场景。,DE算法赋能机器人,优化山地路径规划方案
情侣游戏情侣飞行棋10元真心话大冒险情侣情趣骰子php源码 ----- 程序特色 ----- 1、完整的分销制度,可自定义多种不同的返佣比例 2、支持情侣飞行棋、情趣骰子,多种等级 3、无感微信自动授权登录,支持微信第三方授权登录 4、完全开源无加密
HeidiSQL的12.2.0.6576安装压缩包
监护人,小孩和玩具数据集 4647张原始图片 监护人 食物 孩子 玩具 精确率可达85.4% yolov5pytorch格式
本课程是 PHP 进阶系列之 Swoole 入门精讲,系统讲解 Swoole 在 PHP 高性能开发中的应用,涵盖 协程、异步编程、WebSocket、TCP/UDP 通信、任务投递、定时器等核心功能。通过理论解析和实战案例相结合,帮助开发者掌握 Swoole 的基本使用方法及其在高并发场景下的应用。 适用人群: 适合 有一定 PHP 基础的开发者、希望提升后端性能优化能力的工程师,以及 对高并发、异步编程感兴趣的学习者。 能学到什么: 掌握 Swoole 基础——理解 Swoole 的核心概念,如协程、异步编程、事件驱动等。 高并发处理——学习如何使用 Swoole 构建高并发的 Web 服务器、TCP/UDP 服务器。 实战项目经验——通过案例实践,掌握 Swoole 在 WebSocket、消息队列、微服务等场景的应用。 阅读建议: 建议先掌握 PHP 基础,了解 HTTP 服务器和并发处理相关概念。学习过程中,结合 官方文档和实际项目 进行实践,加深理解,逐步提升 Swoole 开发能力。
机器人先进视觉赛-基于深度学习yolov8的3D识别项目源码含gui界面(最新发布).zip 实现机器人的3D目标识别和分割功能 支持深度图像的处理和分析 【资源详情说明】 【1】该项目为近期精心打造开发,完整代码。同时,配套资料一应俱全,涵盖详细的设计文档 【2】项目上传前源码经过严格测试,在多种环境下均能稳定运行,功能完善且稳定运行,技术研究、教学演示还是项目实践,都能轻松复现,节省时间和精力。 【3】本项目面向计算机相关专业领域的各类人群,对于高校学生,可作为毕业设计、课程设计、日常作业的优质参考;对于科研工作者和行业从业者,可作为项目初期立项演示,助力快速搭建原型,验证思路。 【4】若具备一定技术基础,可在此代码上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 【5】小白,在配置环境或运行项目时遇到困难,可提供远程指导和全方位技术支持。 欢迎下载学习本项目资源,期待与你共同探讨技术问题,交流项目经验!
Matlab实现TSO-XGBoost多变量回归预测 Matlab实现TSO-XGBoost多变量回归预测,金枪鱼算法优化XGBoost多变量回归预测 1.data为数据集,7个输入特征,1个输出特征 2.MainTSO XGboost.m为主程序文件,其他为函数文件,无需运行 3.命令窗口输出R2、MAE、MAE和RMSEP等评价指标,可在下载区获取数据和程序内容 注意程序和数据放在一个文件夹,文件夹不可以XGBoost命名,因为有函数已经用过,运行环境为 Matlab2018及以上,预测效果如下 ,TSO-XGBoost; 多变量回归预测; Matlab实现; 金枪鱼算法优化; 评价指标; 预测效果; 文件夹结构; 运行环境,Matlab中TSO-XGBoost多变量回归预测优化实践
实时音视频SRT协议中文完整版
学习WiFi,入手资料
c语言学习