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

📄 selectlist.java

📁 有关手机游戏网络对战方面的源码
💻 JAVA
字号:
package unicoco;

import java.io.IOException;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;

public class SelectList extends List implements CommandListener {
	static SelectList instance;

	public SelectList(String[] labels, Image[] icons) {
		super("please select one", Choice.EXCLUSIVE, labels, icons);
		setFont(0, Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
				Font.SIZE_LARGE));
		setFont(1, Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
				Font.SIZE_LARGE));
		addCommand(new Command("Back", Command.BACK, 1));
		addCommand(new Command("OK", Command.OK, 1));
		setCommandListener(this);
	}

	public void commandAction(Command c, Displayable d) {
		if (c.getLabel().equalsIgnoreCase("back")) {
			MIDGame.display.setCurrent(MainMenu.getInstance());
		} else if(instance.getSelectedIndex()==0){
			MIDGame.display.setCurrent(Server.getInstance());
		}else{
			MIDGame.display.setCurrent(Client.getInstance());
		}
	}

	public final static Displayable getInstance() {
		if (SelectList.instance == null) {
			String[] labels = { "Server", "Client" };
			Image[] icons = new Image[2];
			try {
				icons[0] = Image.createImage("/serverIcon.png");
				icons[1] = Image.createImage("/clientIcon.png");
			} catch (IOException e) {
//				e.printStackTrace();
				MIDGame.game.notifyDestroyed();
			}
			SelectList.instance = new SelectList(labels, icons);
		}
		return SelectList.instance;
	}

}

⌨️ 快捷键说明

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