📄 languageform.java
字号:
/**
* @(#)LanguageForm.java 1.11 01/08/23
* Copyright (c) 2004-2005 wuhua of workroom Inc. All Rights Reserved.
* @version 1.0, 10/05/2004
* @author 饶荣庆
* @author
*/
package com.j2me.language;
import com.j2me.about.*;
import com.j2me.counter.*;
import com.j2me.main.*;
import javax.microedition.lcdui.*;
/**
*类LanguageForm是用户进行选择语言的界面并监听用户的选择
*/
public class LanguageForm extends Form implements CommandListener, ItemStateListener
{
private Display display = null;
private MainList mainList = null;
public Command okCommand = null; //定义确定软键
public Command backCommand = null; //定义确定软键
public Command cancelCommand = null; //定义确定软键
public Alert infoAlert = null; //初始化警告信息
public ChoiceGroup languageChoice = null; //定义选择框
private boolean isEnglish = false;
private boolean isChinese = false;
public LanguageForm(String s)
{
super(s);
this.okCommand = new Command("确定", Command.OK, 2);
this.backCommand = new Command("返回", Command.EXIT, 2);
this.cancelCommand = new Command("取消", Command.EXIT, 2);
this.infoAlert = new Alert("信息", "是否确定你所作出的选择!",null,AlertType.INFO); //初始化警告信息
this.infoAlert.setTimeout(Alert.FOREVER);
this.infoAlert.addCommand(okCommand);
this.infoAlert.addCommand(cancelCommand);
this.infoAlert.setCommandListener(this);
this.languageChoice = new ChoiceGroup("请选择", ChoiceGroup.EXCLUSIVE);
this.languageChoice.append("简体中文", null);
this.languageChoice.append("English", null);
this.append(languageChoice);
this.addCommand(backCommand);
this.setCommandListener(this);
this.setItemStateListener(this);
}
public void showForm( Display display, MainList mainList)
{
this.display = display;
this.mainList = mainList;
this.display.setCurrent(this);
}
/**
*实现监视器
*/
public void commandAction( Command c, Displayable displayable)
{
if (c == backCommand)
{
this.display.setCurrent(this.mainList);
}
if (c == okCommand)
{
if (isEnglish == true)
{
Language.setEnglish();
}
if (isChinese == true)
{
Language.setChinese();
}
this.display.setCurrent(mainList);
}
if (c == cancelCommand)
{
this.display.setCurrent(this);
}
}
public void itemStateChanged(Item item)
{
if(item == languageChoice)
{
if(languageChoice.isSelected(0) == true) //判断是否对对话框做出选择
{
isEnglish = false;
isChinese = true;
this.display.setCurrent(this.infoAlert);
}
if (languageChoice.isSelected(1) == true)
{
isEnglish = true;
isChinese = false;
this.display.setCurrent(this.infoAlert);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -