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

📄 stringitemdemo.java

📁 里面的工程文件是本人做的一些小程序
💻 JAVA
字号:
package stringitemdemo;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;


public class StringItemDemo extends MIDlet implements
CommandListener,ItemCommandListener{
  static StringItemDemo instance;
  private Display display;
  private Form mainForm;
  Font bigFont,smallFont;
  private Command linkCmd,pressCmd,exitCmd;
  StringItem strItemText,strItemShortText,strItemButton,strItemHYPERLINK;

  public StringItemDemo() {
    instance = this;
    display = Display.getDisplay(this);
    bigFont = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,
                           Font.SIZE_LARGE);
    smallFont = Font.getFont(Font.FACE_PROPORTIONAL,
                             Font.STYLE_ITALIC|Font.STYLE_UNDERLINED,
                             Font.SIZE_SMALL);
    linkCmd = new Command("链接",Command.ITEM,1);
    pressCmd = new Command("按下",Command.ITEM,1);
    exitCmd = new Command("退出",Command.EXIT,1);
    mainForm = new Form("StringItem演示");
    mainForm.append("请选择不同的stringitem对象验证:");
    mainForm.append("\n\n"); //huanhang
    strItemText = new StringItem(
      "文本显示类型的stringtiem对象的长标签内容:",
      "这是长标签文本显示型的stringitem对象中的内容(小字体)");
    strItemText.setFont(smallFont);
    mainForm.append(strItemText);
    mainForm.append("\n\n");

    strItemShortText = new StringItem(
      "短标签文本类型:",
      "这是短标签文本显示型的stringitem对象中的内容(大字体)");
    strItemShortText.setFont(bigFont);
    mainForm.append(strItemShortText);
    mainForm.append("\n\n");

    strItemHYPERLINK = new StringItem(
     "超链接类型:","链接到——>",Item.HYPERLINK);
   strItemHYPERLINK.setFont(bigFont);
   strItemHYPERLINK.setDefaultCommand(linkCmd);
   strItemHYPERLINK.setItemCommandListener(this);
   mainForm.append(strItemHYPERLINK);
   mainForm.append("\n\n");

   strItemButton = new StringItem(
     "按钮类型:", "开始",Item.BUTTON);
   strItemButton.setFont(bigFont);
   strItemButton.setDefaultCommand(pressCmd);
   strItemButton.setItemCommandListener(this);
   mainForm.append(strItemButton);
   mainForm.addCommand(exitCmd);
   mainForm.setCommandListener(this);

  }

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

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command c,Item item){
    if(c==linkCmd)  {
      String text="这里要处理的链接URL^……";
      Alert msgAlert = new Alert("URL提示",text,null,AlertType.INFO);
      display.setCurrent(msgAlert);
    }
    else if(c==pressCmd){
      String text = "这里要处理按钮行为……";
      Alert msgAlert = new Alert("BUTTON提示", text, null, AlertType.INFO);
      display.setCurrent(msgAlert);
    }
  }

  public void commandAction(Command c,Displayable d){
     quitApp();
   }


  public static void quitApp() {
    instance.destroyApp(true);
    instance.notifyDestroyed();
    instance = null;
  }

}

⌨️ 快捷键说明

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