FitPolicyDemo.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.MIDlet;
- public class FitPolicyDemo
- extends MIDlet implements CommandListener {
- private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
- private Display display;
- private ChoiceGroup mChoiceGroup;
- private Form mainForm;
- public FitPolicyDemo() {
- display = Display.getDisplay(this);
- mainForm = new Form("Choice Group演示");
- String mLabel = "到度假胜地,住到预先订好的旅馆房间后,轻松地喘了口气,试着打开窗户时……可看到什么样的景色呢?";
- String[] stringArray = {
- "a可以看见旅馆的游泳池和人群",
- "b看到海边,还可以看见在那里玩的人们",
- "c可以看见远方有一座岛",
- "d窗外是广大的阳台,上面种着五颜六色的花草"
- };
- mChoiceGroup = new ChoiceGroup(mLabel,ChoiceGroup.EXCLUSIVE,stringArray,null);
- mChoiceGroup.setFitPolicy(Choice.TEXT_WRAP_ON);
- mainForm.append(mChoiceGroup);
- mainForm.addCommand(CMD_EXIT);
- mainForm.setCommandListener(this);
- }
- protected void startApp() {
- display.setCurrent(mainForm);
- }
- public void commandAction(Command c, Displayable d) {
- if (c == CMD_EXIT) {
- destroyApp(false);
- notifyDestroyed();
- }
- }
- protected void destroyApp(boolean unconditional) {
- }
- protected void pauseApp() {
- }
- }