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

📄 textbox_alert.java

📁 这是我收集的别人写的关于基本控件的例子
💻 JAVA
字号:
/*
 * 显示一个Alert的屏幕
 */

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class TextBox_Alert extends MIDlet implements CommandListener {

	private Command exitCommand,alertCommand;
	private TextBox tb;

	public TextBox_Alert() {
		exitCommand = new Command("Exit", Command.EXIT, 1);
		alertCommand = new Command("Alert", Command.SCREEN, 1);		
		tb = new TextBox("Alert MIDlet", "Alert Example!", 15, 0);
		
		tb.addCommand(exitCommand);	
		tb.addCommand(alertCommand);
			
		tb.setCommandListener(this);
		
	}
	protected void startApp() throws MIDletStateChangeException {
		Display.getDisplay(this).setCurrent(tb);
	}
	protected void pauseApp() {
	}
	protected void destroyApp(boolean arg0){	

	}
	public void commandAction(Command c, Displayable d) {
		
		if(d == tb && c == alertCommand){
			
			Image img;
			try{
				img = Image.createImage("/Icon.png");
			}
			catch(java.io.IOException e){
				img = null;
			}
			
			Alert info = new Alert("Alert","This is a Alert Example!",img ,AlertType.INFO);
			info.setTimeout(Alert.FOREVER);
			
			Display.getDisplay(this).setCurrent(info,tb);	
			//也可以使用	Display.getDisplay(this).setCurrent(info);返回前一个画面
		}
		
		if (c == exitCommand) {
		
			destroyApp(false);			
			notifyDestroyed();
		}

	}

}

⌨️ 快捷键说明

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