📄 elementnumberscreen.java
字号:
package webservice.midlet;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
public class ElementNumberScreen extends Form
implements CommandListener {
StringItem stringItem1 = new StringItem("", "");
TextField elementField = new TextField("", "", 11, TextField.NUMERIC);
/** 构造器 */
public ElementNumberScreen () {
super("Displayable Title");
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
/**组件初始化*/
private void jbInit () throws Exception {
elementField.setLabel("请输入元素周期表中的元素号:");
//设置事件听众
setCommandListener(this);
//添加命令对象
addCommand(new Command("Submit", Command.SCREEN, 1));
addCommand(new Command("Exit", Command.EXIT, 2));
this.append(stringItem1);
this.append(elementField);
Display.getDisplay(ChemistryMIDlet.chemistryMIDlet).setCurrent(this);
}
/**处理命令事件 */
public void commandAction (Command command, Displayable displayable) {
if (command.getCommandType() == Command.EXIT) {
// 退出MIDlet
ChemistryMIDlet.quitApp();
}
else if (command.getCommandType() == Command.SCREEN) {
String elementNumber = elementField.getString();
Display.getDisplay(ChemistryMIDlet.chemistryMIDlet).setCurrent(
new ElementInfoScreen(elementNumber));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -