📄 spacerdemo.java
字号:
//spacerDemo.java file
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class spacerDemo extends MIDlet implements CommandListener
{
private Command exitCommand, spacerCommand;
private Form mainForm;
public spacerDemo()
{
exitCommand =new Command("Exit",Command.EXIT,1);
spacerCommand =new Command("addSpacer",Command.SCREEN,1);
mainForm = new Form("spacerDemo");
mainForm.addCommand(exitCommand);
mainForm.addCommand(spacerCommand);
//设置命令监听对象
mainForm.setCommandListener(this);
//添加Item对象
mainForm.append("Login");
mainForm.append(new TextField("Name","",10,TextField.ANY));
mainForm.append(new TextField("Password","",6,TextField.PASSWORD));
}
protected void startApp( ) throws MIDletStateChangeException
{
Display.getDisplay(this).setCurrent(mainForm);
}
protected void pauseApp( )
{
}
protected void destroyApp( boolean p1 )
{
}
public void commandAction(Command c,Displayable d)
{
if (c ==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
else if (c ==spacerCommand)
{
mainForm.removeCommand(spacerCommand);
//插入屏幕宽度,高度为5和20象素的Spacer对象
mainForm.insert(2,new Spacer(mainForm.getWidth(), 5));
mainForm.insert(1,new Spacer(mainForm.getWidth(),20));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -