⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 choiceexample.java

📁 《J2ME Game Programming》随书光盘源代码
💻 JAVA
字号:

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class ChoiceExample extends MIDlet implements CommandListener
{
   private Form form;

   public ChoiceExample()
   {
      form = new Form("Choice Example");

      // a simple example of a popup list containing the names of shapes
      ChoiceGroup c = new ChoiceGroup("Shapes", Choice.POPUP);
      c.append("Triangle", null);
      c.append("Square", null);
      c.append("Circle", null);
      form.append(c);

      // create an exlusive style choice with items representing different
      // fonts, then we set that style.
      ChoiceGroup c2 = new ChoiceGroup("Styles", Choice.EXCLUSIVE);
      c2.append("Italic", null);
      c2.append("Bold", null);
      c2.setFont(0, Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_ITALIC,
                             Font.SIZE_SMALL));
      c2.setFont(1, Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
                             Font.SIZE_SMALL));
      form.append(c2);

      // a wide list with wrapping on
      ChoiceGroup c3 = new ChoiceGroup("Wrapped Choice", Choice.EXCLUSIVE);
      c3.append("A long line of text that is too wide for the display", null);
      c3.setFitPolicy(Choice.TEXT_WRAP_ON);
      form.append(c3);

      // a wide list with wrapping off
      ChoiceGroup c4 = new ChoiceGroup("Non-Wrapped Choice", Choice.EXCLUSIVE);
      c4.append("A long line of text that is too wide for the display", null);
      c4.setFitPolicy(Choice.TEXT_WRAP_OFF);
      form.append(c4);

      form.addCommand(new Command("Exit", Command.EXIT, 0));
      form.setCommandListener(this);
   }

   public void startApp()
   {
      Display.getDisplay(this).setCurrent(form);
   }

   public void pauseApp()
   {
   }

   public void destroyApp(boolean unconditional)
   {
   }

   public void commandAction(Command c, Displayable s)
   {
      if (c.getCommandType() == Command.EXIT)
         notifyDestroyed();
   }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -