Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MULTIPLEItemStateListenerDemo.java
Package: J2ME&Game.rar [view]
Upload User: gyyuli
Upload Date: 2013-07-09
Package Size: 3050k
Code Size: 2k
Category:
J2ME
Development Platform:
Java
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.MIDlet;
- public class MULTIPLEItemStateListenerDemo
- extends MIDlet implements CommandListener {
- private final static Command CMD_EXIT = new Command("Exit", Command.EXIT,
- 1);
- private Display display;
- private ChoiceGroup mChoiceGroup;
- private Form mainForm;
- private StringItem mStringItem;
- public MULTIPLEItemStateListenerDemo() {
- display = Display.getDisplay(this);
- mainForm = new Form("Choice Group演示");
- Image[] imageArray = null;
- try {
- Image star = Image.createImage("/star.png");
- imageArray = new Image[] { star, star, star, star, star, star};
- } catch (java.io.IOException err) {
- }
- String[] stringArray = {
- "红心大战","空当接龙","三维弹球","蜘蛛纸牌","翻转棋","扫雷"
- };
- mChoiceGroup = new ChoiceGroup("选择游戏项目",ChoiceGroup.MULTIPLE,stringArray,imageArray);
- mainForm.append(mChoiceGroup);
- mainForm.addCommand(CMD_EXIT);
- mainForm.setCommandListener(this);
- mStringItem = new StringItem("您选择的是","——");
- mainForm.append(mStringItem);
- ItemStateListener listener = new ItemStateListener(){
- public void itemStateChanged(Item item){
- if(item == mChoiceGroup){
- boolean[] selectedArray = new boolean[mChoiceGroup.size()];
- mChoiceGroup.getSelectedFlags(selectedArray);
- StringBuffer selectedString = new StringBuffer();
- for(int i=0;i<selectedArray.length;i++){
- if(selectedArray[i]){
- selectedString.append(" ").append(new StringBuffer(mChoiceGroup.getString(i)));
- }
- }
- mStringItem.setText(selectedString.toString());
- }
- }
- };
- mainForm.setItemStateListener(listener);
- }
- protected void startApp() {
- display.setCurrent(mainForm);
- }
- public void commandAction(Command c, Displayable d) {
- if (c == CMD_EXIT) {
- destroyApp(false);
- notifyDestroyed();
- }
- }
- protected void destroyApp(boolean unconditional) {
- }
- protected void pauseApp() {
- }
- }