stringitemdemo.java

来自「Java ME手机应用开发大全一书的配套光盘上的源码」· Java 代码 · 共 56 行

JAVA
56
字号
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class StringItemDemo extends MIDlet implements CommandListener,ItemCommandListener
                               
{
  private Display display;
  private Form form; 
  private StringItem s1,s2,s3; 
  private Command exit; 
  private Command button;
  private Command link;
  public StringItemDemo()
  {
    display = Display.getDisplay(this);
    s1 = new StringItem("1", "普通模式",StringItem.PLAIN);
    s2 = new StringItem("2", "按钮模式",StringItem.BUTTON);
	s3 = new StringItem("3", "超链接模式",StringItem.HYPERLINK);
    
    exit = new Command("Exit", Command.EXIT, 1);
	button= new Command("Button",Command.ITEM,2);
	link= new Command("link",Command.ITEM,3);
	s2.setDefaultCommand(button);
	s3.setDefaultCommand(link);
	s2.setItemCommandListener(this);
	s3.setItemCommandListener(this);
    form = new Form("各种StringItem外观");    
    form.addCommand(exit);
    form.append(s1);
	form.append(s2);
	form.append(s3);
    form.setCommandListener(this);   
  }
  public void startApp()
  {
    display.setCurrent(form);
  }
  public void pauseApp()
  { 
  }
  public void destroyApp(boolean unconditional)
  { 
  }
  public void commandAction(Command command, Displayable displayable)
  {
   if (command == exit)
    {
     destroyApp(false);
     notifyDestroyed();
    }
  }
  public void commandAction(Command command,Item item)
	{

	}
}

⌨️ 快捷键说明

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