viewerform.java

来自「这是一个Java编写的手机象棋游戏」· Java 代码 · 共 54 行

JAVA
54
字号
import javax.microedition.lcdui.*;

public class ViewerForm extends Form implements CommandListener
{
	private Command		exit=null,viewer=null, publicViewer;
	private MainSelect	mainSelect=null;
	private ChoiceGroup	saveChoice, musicChoice, soundChoice;
	private String		saveChoiceString[]={"不保存","保存"}, musicChoiceString[] = {"打开","关闭"} ,soundChoiceString[] = {"打开","关闭"};

	public ViewerForm(MainSelect ms)
	{
		super("看擂设置");
		mainSelect=ms;
		//*********界面初始化
		saveChoice=new ChoiceGroup("是否保存记录",Choice.EXCLUSIVE,saveChoiceString,null);
		musicChoice=new ChoiceGroup("背景音乐",Choice.EXCLUSIVE,musicChoiceString,null);
		soundChoice=new ChoiceGroup("走步提示",Choice.EXCLUSIVE,soundChoiceString,null);
		append(saveChoice);
		append(musicChoice);
		append(soundChoice);
		//*********命令初始化
		exit=new Command("Exit",Command.EXIT,1);
		viewer=new Command("电台",Command.OK,1);
		publicViewer =new Command("观众",Command.OK,1);
		addCommand(exit);
		addCommand(viewer);
		addCommand(publicViewer);
		setCommandListener(this);
	}

	public void commandAction(Command com,Displayable dis)
	{
		if(com==exit)
		{
			Chess.dis.setCurrent(mainSelect);
		}
		else
		{
			int	saveIndex=saveChoice.getSelectedIndex();
			int	musicIndex=musicChoice.getSelectedIndex();
			int	soundIndex=soundChoice.getSelectedIndex();
			if(com==viewer)
			{
				ViewerCanvas viewerCanvas = new ViewerCanvas(mainSelect, saveIndex, musicIndex, soundIndex);
				Chess.dis.setCurrent(viewerCanvas);
			}
			if(com==publicViewer)
			{
				PublicCanvas publicCanvas = new PublicCanvas(mainSelect, saveIndex, musicIndex, soundIndex);
				Chess.dis.setCurrent(publicCanvas);
			}
		}
	}
};

⌨️ 快捷键说明

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