📄 coursesmanager.java
字号:
package coursesManager;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class CoursesManager extends MIDlet implements CommandListener,ItemCommandListener{
private Form mainForm,loginForm;
private CourseForm courseForm;
private Display display;
private boolean firstTime,firstLogin;
private Command EXIT_CMD,LOGIN_CMD;
private StringItem[] week;
private StringItem[][] courses;
private Command[][] CMD_OK;
private TextField password;
public CoursesManager() {
display=Display.getDisplay(this);
EXIT_CMD=new Command("退出",Command.EXIT,1);
firstTime=true;
firstLogin=true;
}
protected void destroyApp(boolean arg0) {
// TODO 自动生成方法存根
}
protected void pauseApp() {
// TODO 自动生成方法存根
}
protected void startApp() {
if(firstLogin){
password=new TextField("请输入密码:",null,20,TextField.PASSWORD);
loginForm=new Form("登陆界面");
loginForm.append(password);
LOGIN_CMD=new Command("登陆",Command.OK,2);
loginForm.addCommand(EXIT_CMD);
loginForm.addCommand(LOGIN_CMD);
loginForm.setCommandListener(this);
firstLogin=false;
display.setCurrent(loginForm);
}
else{
mainForm();
}
}
public void commandAction(Command com, Displayable dis) {
if(com==EXIT_CMD){
destroyApp(false);
notifyDestroyed();
}
if(com==LOGIN_CMD){
if(password.getString().equals("123")){
mainForm();
}
else{
password.setString("");
Alert alert=new Alert("密码错误");
alert.setString("密码错误");
display.setCurrent(alert,loginForm);
}
}
}
public void commandAction(Command com, Item item) {
for(int i=0;i<5;i++){
for(int j=0;j<7;j++){
if(com==CMD_OK[i][j]){
courseForm=new CourseForm("详细信息",display,mainForm,i,j);
display.setCurrent(courseForm);
}
}
}
}
public void mainForm(){
if(firstTime==true){
mainForm=new Form("课程表");
mainForm.append("欢迎使用课程表\n");
week = new StringItem[7];
week[0] = new StringItem(null, "日");
week[1] = new StringItem(null, "一");
week[2] = new StringItem(null, "二");
week[3] = new StringItem(null, "三");
week[4] = new StringItem(null, "四");
week[5] = new StringItem(null, "五");
week[6] = new StringItem(null, "六");
for (int i = 0; i < 7; i++) {
mainForm.append(week[i]);
mainForm.append(new Spacer(21, 15));
}
mainForm.append("\n");
courses = new StringItem[5][7];
for (int i = 0; i < 7; i++) {
courses[0][i] = new StringItem(null, "12", Item.PLAIN);
courses[1][i] = new StringItem(null, "34", Item.PLAIN);
courses[2][i] = new StringItem(null, "56", Item.PLAIN);
courses[3][i] = new StringItem(null, "78", Item.PLAIN);
courses[4][i] = new StringItem(null, "90", Item.PLAIN);
}
CMD_OK=new Command[5][7];
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 7; j++) {
mainForm.append(courses[i][j]);
CMD_OK[i][j]=new Command("查看",Command.OK,2);
courses[i][j].setItemCommandListener(this);
courses[i][j].setDefaultCommand(CMD_OK[i][j]);
mainForm.append(new Spacer(20, 15));
}
mainForm.append("\n");
}
mainForm.addCommand(EXIT_CMD);
mainForm.setCommandListener(this);
firstTime=false;
}
display.setCurrent(mainForm);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -