📄 spacerdemo.java
字号:
package ch04;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class spacerDemo
extends MIDlet
implements CommandListener {
private Command exitCommand, spacerCommand;
private Form form;
public spacerDemo() {
exitCommand = new Command("Exit", Command.EXIT, 1);
spacerCommand = new Command("addSpacer", Command.SCREEN, 1);
form = new Form("spacerDemo");
form.addCommand(exitCommand);
form.addCommand(spacerCommand);
//设置命令监听对象
form.setCommandListener(this);
//添加Item对象
form.append("Login");
form.append(new TextField("Name", "", 10, TextField.ANY));
form.append(new TextField("Password", "", 6, TextField.PASSWORD));
}
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 == spacerCommand) {
form.removeCommand(spacerCommand);
//插入屏幕宽度,高度为5和20象素的Spacer对象
form.insert(2, new Spacer(form.getWidth(), 5));
form.insert(1, new Spacer(form.getWidth(), 20));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -