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

📄 mulistmidlet.java

📁 j2me接口的例子,很不错的东东 可以做教程
💻 JAVA
字号:
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class MuListMIDlet extends MIDlet implements CommandListener {

    private Command exitComm;
    private Command confirmComm;

    private List list;
    private Display display;

    String[] program = {
        "Java", "C++", "C", "C#"};

 
    Image[] proImage = {
        createImage("/TilePuzzle.png"),
        createImage("/Auction.png"),
        createImage("/ManyBalls.png"),
        createImage("/App.png")};

    
    public MuListMIDlet() {

        display = Display.getDisplay(this);

        exitComm = new Command("离开", Command.EXIT, 1);
        confirmComm = new Command("确认", Command.SCREEN, 1);

    }

    public void startApp() {
    	
        list = new List("兴趣", List.MULTIPLE, program, proImage);
        list.addCommand(exitComm);
        list.addCommand(confirmComm);
      
        list.setCommandListener(this);
        display.setCurrent(list);

      
    }

    public void pauseApp() {}

    public void destroyApp(boolean unconditional) {}

    private Image createImage(String name) {
        Image aImage = null;
        try {
            aImage = Image.createImage(name);
        } catch (IOException e) {
        }
        return aImage;
    }

    public void commandAction(Command c, Displayable s) {
    	String comm = c.getLabel();
        if (comm.equals("离开")) {
                destroyApp(false);
                notifyDestroyed();
        }
        if (comm.equals("确认")) {
              
            String result = "你喜欢的编程语言是:\n";
           
            for (int i = 0; i < list.size(); i++){
               
               if (list.isSelected(i)){
               	
                     result=result + program[i] + ", ";
               }
            }
            
            Alert alert = new Alert("结果", result, null, AlertType.INFO);
            alert.setTimeout(6000);
            display.setCurrent(alert);
 
       }         
    
    }

}

⌨️ 快捷键说明

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