佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1937|回复: 7

j2ME POLISH

[复制链接]
发表于 12-12-2006 02:37 PM | 显示全部楼层 |阅读模式
package de.enough.polish.example;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import de.enough.polish.util.Locale;

//#ifdef polish.debugEnabled
//#         import de.enough.polish.util.Debug;
//#endif
       
/**
* <p>Shows a demonstration of the possibilities of J2ME Polish.</p>
*
* <p>Copyright Enough Software 2004, 2005</p>

* <pre>
* history
*        04-Apr-2004 - rob creation
* </pre>
* @author Robert Virkus, j2mepolish@enough.de
*/
public class MenuMidlet extends MIDlet implements CommandListener {
       
        List menuScreen;
        Command startGameCmd = new Command( Locale.get( "cmd.StartGame" ), Command.ITEM, 8 );
        Command quitCmd = new Command( Locale.get("cmd.Quit", Command.EXIT, 10 );
        //#ifdef polish.debugEnabled
//#                 Command showLogCmd = new Command( Locale.get("cmd.ShowLog", Command.ITEM, 9 );
        //#endif
        Display display;
       
        public MenuMidlet() {
                super();
                //#debug
                System.out.println("starting MenuMidlet";
                //#ifdef title:defined
                        //#= String title = "${ title }";
                //#else
                        String title = "J2ME Polish";
                //#endif
                //#style mainScreen
                this.menuScreen = new List(title, List.IMPLICIT);
                //#style mainCommand
                this.menuScreen.append( Locale.get( "menu.StartGame", null);
                //#style mainCommand
                this.menuScreen.append(Locale.get( "menu.LoadGame", null);
                //#style mainCommand
                this.menuScreen.append(Locale.get( "menu.Highscore", null);
                //#style mainCommand
                this.menuScreen.append(Locale.get( "menu.Quit", null);
               
               
                this.menuScreen.setCommandListener(this);
                this.menuScreen.addCommand( this.startGameCmd );
                this.menuScreen.addCommand( this.quitCmd );

               
                //#ifdef polish.debugEnabled
//#                
//#                 
                //#endif
               
                // You can also use further localization features like the following:
                //System.out.println("Today is " + Locale.formatDate( System.currentTimeMillis() ));
               
                //#debug
                System.out.println("initialisation done.";
        }

        protected void startApp() throws MIDletStateChangeException {
                //#debug
                System.out.println("setting display.";
                this.display = Display.getDisplay(this);
                this.display.setCurrent( this.menuScreen );
                //#debug
                System.out.println("sample application is up and running.";
        }

        protected void pauseApp() {
                // ignore
        }
       
        protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
                // just quit
        }
       
        public void commandAction(Command cmd, Displayable screen) {               
                if (screen == this.menuScreen) {
                        //#ifdef polish.debugEnabled
//#                                 if (cmd == this.showLogCmd ) {
//#                                         Debug.showLog(this.display);
//#                                         return;
//#                                 }
                        //#endif
                        if (cmd == List.SELECT_COMMAND) {
                                int selectedItem = this.menuScreen.getSelectedIndex();
                                switch (selectedItem) {
                                        case 0: startGame(); break;
                                        case 1: loadGame(); break;
                                        case 2: showHighscore(); break;
                                        default: notifyDestroyed();
                                }
                        } else if (cmd == this.startGameCmd) {
                                startGame();
                        } else if (cmd == this.quitCmd) {
                                quit();
                        }
                }
        }
       
        private void startGame() {
                Alert alert = null;
                //#= alert = new Alert( "Welcome", Locale.get( "messages.welcome", "${user.name}" ), null, AlertType.INFO );
                alert.setTimeout( Alert.FOREVER );
                this.display.setCurrent( alert, this.menuScreen );
               
        }
       
        private void loadGame() {
                //#style loadGameAlert
                Alert alert = new Alert( "Sorry", "load game not implemented", null, AlertType.INFO );
                alert.setTimeout( 3000 );
                this.display.setCurrent( alert );
        }
       
        private void showHighscore() {
                Alert alert = new Alert( "Sorry", "highscore not implemented", null, AlertType.INFO );
                alert.setTimeout( Alert.FOREVER );
                this.display.setCurrent( alert, this.menuScreen );
        }
       
        private void quit() {
                notifyDestroyed();
        }
       
}



那个红色的编写,我不理解。。但是我了解是展出POP OUT MENU。。假如我要START GAMES 也展出POP OUT MENU,我应该怎样。。?
回复

使用道具 举报


ADVERTISEMENT

发表于 14-1-2007 08:27 PM | 显示全部楼层
  1. Command startGameCmd = new Command( Locale.get( "cmd.StartGame" ), Command.ITEM, 8 );
  2. Command quitCmd = new Command( Locale.get("cmd.Quit"), Command.EXIT, 10 );
复制代码


这个就是command.
回复

使用道具 举报

 楼主| 发表于 15-1-2007 02:18 PM | 显示全部楼层
我知道了,无论如合谢谢你

要加

UiAccess.addSubCommand(this.aa,this.startGameCmd,this.menuScreen);
UiAccess.addSubCommand(this.bb,this.startGameCmd,this.menuScreen);
回复

使用道具 举报

发表于 19-1-2007 08:20 AM | 显示全部楼层
喔!!!J2ME哟!!!

每每看到別人在讨论开发游戏我心中就会燃起无明火
回复

使用道具 举报

发表于 20-1-2007 10:18 PM | 显示全部楼层
原帖由 godchild 于 19-1-2007 08:20 AM 发表
喔!!!J2ME哟!!!

每每看到別人在讨论开发游戏我心中就会燃起无明火


什么无名火? j2me 现在好像是叫java me了
回复

使用道具 举报

发表于 21-1-2007 04:28 PM | 显示全部楼层
个人觉得游戏是一种最具挑战的程式,因为极需富创意的脑袋和良好的逻辑思维.
众所周知,创意和逻辑都是相对的思维运作,可谓是全脑的运用喔!!
回复

使用道具 举报

Follow Us
发表于 23-1-2007 07:52 PM | 显示全部楼层
原帖由 godchild 于 21-1-2007 04:28 PM 发表
个人觉得游戏是一种最具挑战的程式,因为极需富创意的脑袋和良好的逻辑思维.
众所周知,创意和逻辑都是相对的思维运作,可谓是全脑的运用喔!!


左右脑并用, 强!难道您是java me 高手? 未请教。
回复

使用道具 举报

发表于 30-1-2007 11:03 AM | 显示全部楼层
原帖由 Jerome^18 于 23-1-2007 07:52 PM 发表


左右脑并用, 强!难道您是java me 高手? 未请教。


高不高就不是很清楚啦,170而已.哈哈...开玩笑的,情別见怪.

个人觉得在这世界里沒所谓的高手或低手(天才除外),只有勤劳与否而已.我能力还算可以吧,能应付一般的编程需求.
回复

使用道具 举报


ADVERTISEMENT

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 28-8-2025 09:29 PM , Processed in 0.110968 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表