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

📄 helpui.java

📁 移动图书馆 用j2me 加 jsp servlet 开发 环境 netbeans + tomcat
💻 JAVA
字号:
/*
 * HelpUI.java
 *
 * Created on 2006年5月11日, 下午12:07
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package cn.edu.uestc.pandawireless.ui;
import javax.microedition.lcdui.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
 *
 * @author 熊猫晓希
 */
public class HelpUI extends Form implements CommandListener {
    private UIControler uicontroler;
    
    private static final Command backCommand = new Command("返回",Command.BACK,2);
    
    /** Creates a new instance of HelpUI */
    public HelpUI(UIControler uicontroler) {
        super(Title.helpTitle);
        this.uicontroler = uicontroler;
        Image image = buildImage("/image/baby.png");
        this.append(image);
        String text = "";
        try{
             text = getText("/text/welcome.txt");
        }catch (IOException ex){
             text = "读取文本出错";
        }
        this.append("\n"+text);
        this.addCommand(backCommand);
        this.setCommandListener(this);
        
    }
    
     private Image buildImage(String path){
        Image image = null;
        try{
            image = Image.createImage(path);
        }catch (IOException ex){
            ex.printStackTrace();
        }
        return image;
    }
     /** read help-text from .txt file*/
    private String getText(String path) throws IOException{
        InputStream is = getClass().getResourceAsStream(path);
        if(is != null){
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            int ch = 0;
            while((ch = is.read()) != -1){
                baos.write(ch);
            }
            byte[] text = baos.toByteArray();
            baos.close();
            return new String(text,"UTF-8");
        }else{
            return "无法读取文本";
        }
            
    }
    public void commandAction(Command cmd,Displayable displayable){
        if(cmd == backCommand){
            uicontroler.handleEvent(UIControler.EventID.HELP_BACKTO_MAINMENU);
        }
        
    }
    
}

⌨️ 快捷键说明

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