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

📄 midlet8.java

📁 这是郭克华老师的J2ME视频的源代码
💻 JAVA
字号:
package prj4_1;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class MIDlet8 extends MIDlet implements CommandListener{
	private TextBox tbx = new TextBox("请您输入短信","",255,TextField.ANY);
	private Display dis;	
	
	private Command cmdDelete = new Command("删除文本",Command.SCREEN,1);	
	private Alert alert1 = null;
	
	public MIDlet8(){
		Image img = null;
		try{
			img = Image.createImage("/img.png");
		}catch(Exception ex){
			ex.printStackTrace();
		}
		alert1 = new Alert("提示","有短信,是否阅读?",img,AlertType.INFO);
	}
	
	
	protected void startApp() throws MIDletStateChangeException {
		dis = Display.getDisplay(this);
		//dis.setCurrent(alert1,tbx);//消失之后到达tbx
		alert1.setTimeout(Alert.FOREVER);
		dis.setCurrent(alert1);
		tbx.addCommand(cmdDelete);
		
		tbx.setCommandListener(this);
	}	
	
	public void commandAction(Command c, Displayable d) {		
		if(c==cmdDelete){
			//删除光标前的一个字符
			int position = tbx.getCaretPosition();
			tbx.delete(position-1, 1);
		}

	}
	
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {

	}

	protected void pauseApp() {

	}



}

⌨️ 快捷键说明

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