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

📄 baseview.java

📁 手机记事本程序
💻 JAVA
字号:
/*
 * Created on 2005-3-3
 *
 * MVC模型
 */
package com.favo.ui;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;

/**
 * @author Favo
 *
 * 视图类
 */
public abstract class BaseView {
	
	public abstract Display getDisplay();
	
	/**
	 * 简单的返回包装的屏幕对象,不要做任何准备屏幕的操作!
	 */
	public abstract Displayable getScreen();
	
	/**
	 * 创建屏幕
	 */
	protected abstract void createView() throws Exception;
	
	/**
	 * 更新屏幕
	 */
	public abstract void updateView() throws Exception;
		
	/**
	 * 返回控制器
	 */
	public abstract BaseController getController();
	
	/**
	 * 准备屏幕
	 * 返回准备好的屏幕对象
	 */
	public Displayable prepareScreen() throws Exception {
		if(getScreen()==null){
			createView();
		} else {
			updateView();
		}
		return getScreen();
	}
	
	/**
	 * 显示当前屏幕
	 */
	public void displayScreen(){
		try{
			getDisplay().setCurrent(prepareScreen());
		} catch (Exception e) {
			e.printStackTrace();
			Alert al=new Alert("Error",e.toString()+'\n'+e.getMessage(),null,AlertType.ERROR);
			al.setTimeout(Alert.FOREVER);
			getDisplay().setCurrent(al);
		}
	}
	
}

⌨️ 快捷键说明

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