贴出我第一个手机Java程序

来源:互联网 发布:商派onex 源码下载 编辑:程序博客网 时间:2024/04/30 11:57
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import java.io.*;

public class Mobile extends MIDlet {

    
private Display display = null;
    
    
public Mobile() {
        
// TODO 自动生成构造函数存根

    }


    
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
        
// TODO 自动生成方法存根

    }


    
protected void pauseApp() {
        
// TODO 自动生成方法存根

    }


    
protected void startApp() throws MIDletStateChangeException {
        
//获得Display实例

        display 
= Display.getDisplay(this);
        
            
        Form mainForm 
= new Form("Made by Jack");
        Image img 
= null;
        
//创建Image对象
        try{
            img 
= Image.createImage("/_home_8.png");
        }
catch(IOException ex){
            ex.printStackTrace();
        }

        
        
if(img != null)
            mainForm.append(img);
        
        String str 
= new String("/n我的第一个手机Java程序");
        
        mainForm.append(str);

        display.setCurrent(mainForm);    
        
    }

}

 

这是一个显示一张图和在下面一串文字的Demo,我的第一个程序。图片放在res文件夹内。

原创粉丝点击