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

📄 fullscreen.java

📁 《精通JAVA手机游戏与应用程序设计》随书光盘
💻 JAVA
字号:


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


public class fullScreen extends MIDlet implements CommandListener {

	private Command exitCommand;
	private Command showCommand;
	private Command fullCommand;
	private fullScreenCanvas sg;

	public fullScreen() {
		exitCommand = new Command("退出", Command.EXIT, 1);
		showCommand = new Command("正常", Command.SCREEN, 1);
		fullCommand = new Command("全屏", Command.SCREEN, 1);
		sg = new fullScreenCanvas();
		sg.addCommand(exitCommand);		
		sg.addCommand(fullCommand);
		sg.setCommandListener(this);
		
		
	}
	protected void startApp(){
		Display.getDisplay(this).setCurrent(sg);
	}

	protected void pauseApp() {
	}

	protected void destroyApp(boolean arg0){		
	}
	public void commandAction(Command c, Displayable d) {
		if (c == exitCommand) {			
			destroyApp(false);			
			notifyDestroyed();
		}
		if (c == showCommand) {	
			sg.addCommand(fullCommand);
			sg.removeCommand(showCommand);
			sg.show();	
			
			
		}
		if (c == fullCommand) {		
			sg.removeCommand(fullCommand);
			sg.addCommand(showCommand);
			sg.full();
			
			
		}
	}	
}

class fullScreenCanvas extends Canvas{
	private boolean fulled = false;//cleared 表示被清除了
	protected fullScreenCanvas(){
		fulled = false;
	}
	protected void paint(Graphics g) {		
		if(!fulled){
			//先清屏,后显示字符串
			g.setColor(255,255,255);
			g.fillRect(0,0,getWidth(),getHeight());
			g.setColor(0,0,0);
			g.drawString("目前状态:正常屏幕", this.getWidth()/2, this.getHeight()/2,
				Graphics.BOTTOM|Graphics.HCENTER);
		}
		else{
			//先清屏,后显示字符串
			g.setColor(255,255,255);
			g.fillRect(0,0,getWidth(),getHeight());
			g.setColor(0,0,0);
			g.drawString("目前状态:全屏", this.getWidth()/2, this.getHeight()/2,
					Graphics.BOTTOM|Graphics.HCENTER);
			fulled = true;
		}		
	}
	public void full(){
		 setFullScreenMode(true);
		fulled = true;			
		repaint();
	}
	public void show(){
		setFullScreenMode(false);		
		fulled = false;			
		repaint();
	}
	
}

⌨️ 快捷键说明

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