📄 gaugedemo3.java
字号:
//gaugeDemo3.java file
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import itemex.*;
public class gaugeDemo3 extends MIDlet implements CommandListener
{
private Command exitCommand, aCommand1, aCommand2;
private Form form;
private GaugeAlert alert;
public gaugeDemo3()
{
exitCommand =new Command("Exit",Command.EXIT,1);
aCommand1 =new Command("Alert Forever",Command.SCREEN,2);
aCommand2 =new Command("Alert timeout",Command.SCREEN,2);
form = new Form("gauge form 3");
form.append("GaugeAlert Demo");
form.addCommand(exitCommand);
form.addCommand(aCommand1);
form.addCommand(aCommand2);
//设置命令监听对象
form.setCommandListener(this);
}
protected void startApp( ) throws MIDletStateChangeException
{
Display.getDisplay(this).setCurrent(form);
}
protected void pauseApp( )
{
}
protected void destroyApp( boolean p1 )
{
}
public void commandAction(Command c,Displayable d)
{
if (c ==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
else if (c ==aCommand1)
{//显示不会自动消失的警告窗口
alert = new GaugeAlert("GaugeAlert", "Alert without timeout", null,null,Alert.FOREVER);
Display.getDisplay(this).setCurrent(alert, form);
}
else if (c ==aCommand2)
{//显示10秒钟自动消失的警告窗口
alert = new GaugeAlert("GaugeAlert","Alert timeout=10s", null,null, 10000);
Display.getDisplay(this).setCurrent(alert, form);
}
else if(c ==Alert.DISMISS_COMMAND)
{//处理警告窗口退出的命令
//必须手工设置当前需要显示的对象
Display.getDisplay(this).setCurrent(form);
alert = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -