spacerexample.java

来自「《J2ME Game Programming》随书光盘源代码」· Java 代码 · 共 61 行

JAVA
61
字号

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

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

   public SpacerExample()
   {
      form = new Form("Spacer Example");

      // ROW 1 -----------------
      SmileyItem s1 = new SmileyItem("Smile 1");
      s1.setLayout(Item.LAYOUT_EXPAND | Item.LAYOUT_2);
      form.append(s1);

      // add a spacer in between the two smileys on the first row
      form.append(new Spacer(30, 30));

      // add the second smiley
      form.append(new SmileyItem("Smile 2"));

      // ROW 2 -------------------
      form.append(new SmileyItem("Smile 3"));

      // add a spacer in between the two smileys on the second row
      form.append(new Spacer(30, 30));

      SmileyItem s4 = new SmileyItem("Smile 4");

      // expand the second smiley (expanding)
      s4.setLayout(Item.LAYOUT_EXPAND | Item.LAYOUT_2);
      form.append(s4);

      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 + =
减小字号Ctrl + -
显示快捷键?