josn1984

          常用鏈接

          統(tǒng)計(jì)

          最新評(píng)論

          置頂隨筆 #

          [置頂]此J2ME程序已經(jīng)完善,貼出來(lái)大家看看(可惜我沒(méi)能及時(shí)做注釋,還請(qǐng)大家見諒)

          這個(gè)是主文件(后面的是執(zhí)行的操作文件):
          import javax.microedition.midlet.*;
          import javax.microedition.lcdui.*;

          public class LostInForest extends MIDlet implements CommandListener{
           
           private Display display;
           private Canvas canvas;
           private Command exitCmd;
           MenuScreen menuScreen = new MenuScreen();
           MyGameCanvas gameCanvas = new MyGameCanvas();
           
           private Command exitGame;
           Alert aAlert = new Alert("Game Method","Login the game,point up,down,left,right contron",null,AlertType.INFO);
           Alert bAlert = new Alert("Maker","our",null,AlertType.INFO);
           
           public LostInForest(){
            exitCmd = new Command("exit",Command.EXIT,2);
            exitGame = new Command("Exit Game",Command.EXIT,1);
            aAlert.setTimeout(10000);
            bAlert.setTimeout(10000);
            aAlert.addCommand(exitCmd);
            bAlert.addCommand(exitCmd);


            gameCanvas.addCommand(exitGame);
            gameCanvas.setCommandListener(this);
            aAlert.setCommandListener(this);
            bAlert.setCommandListener(this);
           }
           public void startApp() throws MIDletStateChangeException{
            canvas = new MenuScreen();
            display = Display.getDisplay(this);
            display.setCurrent(canvas);
           }
           public void pauseApp(){}
           public void destroyApp(boolean b){}
           public void commandAction(Command cmd,Displayable dis){
            if(cmd == exitCmd){
             display.setCurrent(menuScreen);
            }
            else if(cmd == exitGame){
             System.gc();
             destroyApp(false);
             notifyDestroyed();
            }
           }
           class MenuScreen extends Canvas implements Runnable{
            final Font lowFont = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
            final Font highFont = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE);
            final int lowColor = 0x000000AA;
            final int highColor = 0x00FF0000;
            final int highBGColor = 0x00AAAAAA;
            int width;
            int height;
            int startHeight;
            int menuHeight;
            final int spacing = highFont.getHeight()/2;
            final String[] mainMenu = {"Start Game","Game Method","Worker","Exit"};
            int menuIdx;
            Thread menuThread;
            
            public MenuScreen(){
             width = getWidth();
             height = getHeight();
             menuHeight = (highFont.getHeight() * mainMenu.length)+((mainMenu.length-1)*spacing);
             startHeight = (height - menuHeight)/2+4;
             menuIdx = 0;
             menuThread = new Thread(this);
             menuThread.start();
            }
            public void run(){
             while(true){
              repaint();
             }
            }
            public void paint(Graphics g){
             g.setColor(0x00FFFF00);
             g.fillRect(0,0,width,height);
             
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             Font label1 = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE);
             g.drawString("LostInForest",62,label1.getHeight()/2,Graphics.TOP|Graphics.LEFT);
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             g.drawString("LostInForest",0,24,Graphics.TOP|Graphics.LEFT);
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             g.drawString("Copyright@2007 SZPT",25,145,Graphics.LEFT|Graphics.TOP);
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             g.drawString("All Rights Reserved.",30,160,Graphics.LEFT|Graphics.TOP);
             
             for(int i = 0;i<mainMenu.length;i++){
              if(i == menuIdx){
               g.setColor(highBGColor);
               g.fillRect(0,startHeight + (i*highFont.getHeight())+spacing,width,highFont.getHeight());
               g.setFont(highFont);
               g.setColor(highColor);
               g.drawString(mainMenu[i],(width - highFont.stringWidth(mainMenu[i]))/2,startHeight+(i*highFont.getHeight())+spacing,20); 
              }
              else{
             g.setFont(lowFont);
             g.setColor(lowColor);
             g.drawString(mainMenu[i],(width - highFont.stringWidth(mainMenu[i]))/2,startHeight+(i*highFont.getHeight())+spacing,20);
                    }
             }
            }
            protected void keyPressed(int code){
             if(getGameAction(code) == Canvas.UP&&menuIdx - 1 >= 0){
              menuIdx--;
             }
             else if(getGameAction(code) == Canvas.DOWN&&menuIdx + 1 < mainMenu.length){
              menuIdx ++;
             }
             if(getGameAction(code) == Canvas.FIRE){
              if(mainMenu[menuIdx] == "Start Game"){
               gameCanvas.start();
               display.setCurrent(gameCanvas);
               }
              else if(mainMenu[menuIdx] == "Game Method"){
               display.setCurrent(aAlert);
              }
              else if(mainMenu[menuIdx] == "Maker"){
               display.setCurrent(bAlert);
              }
              else if(mainMenu[menuIdx] == "Exit"){
               notifyDestroyed();
              }
             }
            } 
           }
          }
          這個(gè)是主操作文件:
          import javax.microedition.lcdui.*;
          import javax.microedition.lcdui.game.*;
          import javax.microedition.rms.*;

          public class MyGameCanvas extends GameCanvas implements Runnable{
           private boolean isPlay;
           private long delay;
           private int currentX,currentY;
           private int width;
           private int height;
           Graphics g;
           public Display display;
           Image image = null;
           Image tileImages = null;
           private Sprite spriteRole;
           private static int INDEX_OF_UP = 0;
           private static int INDEX_OF_DOWN = 1;
           private static int INDEX_OF_LEFT = 3;
           private static int INDEX_OF_RIGHT = 2;
           private TiledLayer tiledBackground;
           private TiledLayer tiledLayer = null;
           private LayerManager layerManager;
           private RecordStore rs = null;
           private int gameLifeValueInt = 3;
           private String gameLifeValueString = null;
           private int firstGate = 0;
           private int[] map = {
           };
           
           public MyGameCanvas(){
            super(true);
            width = getWidth() - 20;
            height = getHeight() - 17;
            currentX = 160;
            currentY = 160;
            delay = 20;
            g = getGraphics();
            try{
             image = Image.createImage("/player.png");
             spriteRole = new Sprite(image,16,16);
             tileImages = Image.createImage("/tiles.png");
             tiledLayer = new TiledLayer(12,12,tileImages,16,16);
             tiledBackground = initBackground();
             layerManager = new LayerManager();
             layerManager.append(tiledBackground);
             layerManager.append(spriteRole);
             IntToString();
             createNewDB();
             setRecordToDB(1,gameLifeValueString,0,1);
            }
            catch(Exception e){
             e.printStackTrace();
            }
           }
           public void start(){
            isPlay = true;
            Thread t = new Thread(this);
            t.start();
           }
           public void stop(){
            isPlay = false;
           }
           public void run(){
            while(isPlay){
             input();
             drawScreen(g);
             try{
              Thread.sleep(delay);
             }
             catch(InterruptedException ie){}
            }
           }
           private void IntToString(){
            gameLifeValueString = gameLifeValueInt + "";
           }
           private void createNewDB(){
            try{
             rs = RecordStore.openRecordStore("GameDB",true);
            }
            catch(RecordStoreNotFoundException rsnfe){}
            catch(RecordStoreFullException rsfe){}
            catch(RecordStoreException rse){}
           }
           private void addRecordToDB(String str){
            byte rec[] = str.getBytes();
            try{
             rs.addRecord(rec,0,rec.length);
            }
            catch(RecordStoreFullException rse){}
            catch(RecordStoreException rse){}
           }
           private String getRecordFromDB(){
            byte data[] = new byte[5];
            int dataLength = 0;
            try{
             dataLength = rs.getRecord(1,data,0);
            }
            catch(RecordStoreException rse){}
            return new String(data,0,dataLength);
           }
           private void setRecordToDB(int recordID,String str,int offset,int len){
            try{
             byte data[] = str.getBytes();
             rs.setRecord(recordID,data,offset,len);
            }
            catch(RecordStoreException rse){}
           }
           private void input(){
            int keyStates = getKeyStates();
            try{
             if((keyStates&LEFT_PRESSED)!=0&&gameLifeValueInt > 0){
              int tempX = Math.max(0,currentX - 16);
              int tempPoint = tempX/16+currentY*12/16;
              if(map[tempPoint]==1){
               currentX = tempX;
              }
              else if(map[tempPoint]==5){
               currentX = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentX  = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_LEFT);
             }
            else if((keyStates&RIGHT_PRESSED)!=0&&gameLifeValueInt>0){
             int tempX = Math.min(width,currentX + 16);
             int tempPoint = tempX/16+currentY*12/16;
              if(map[tempPoint]==1){
               currentX = tempX;
              }
              else if(map[tempPoint]==5){
               currentX = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentX  = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_RIGHT);
            }
            else if((keyStates&UP_PRESSED)!=0&&gameLifeValueInt > 0){
             int tempY = Math.max(0,currentY - 16);
             int tempPoint = currentX/16+tempY*12/16;
              if(map[tempPoint]==1){
               currentY = tempY;
              }
              else if(map[tempPoint]==5){
               currentY = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentY = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }   
              else if(map[tempPoint]==2){
               currentY  = tempY;
               try{
                firstGate = 100;
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_UP);
            }
            else if((keyStates&DOWN_PRESSED)!=0&&gameLifeValueInt>0){
             if(currentY + 10<height){
             int tempY = Math.min(height,currentY + 16);
             int tempPoint = currentX/16+tempY*12/16;
              if(map[tempPoint]==1){
               currentY = tempY;
              }
              else if(map[tempPoint]==5){
               currentY = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentY  = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_DOWN);
             }
            }
             }
           catch(ArrayIndexOutOfBoundsException e){}
           }
           
           public void drawScreen(Graphics g){
           g.setColor(0x00FFFFFF);
           g.fillRect(22,22,getWidth(),getHeight());
           layerManager.append(tiledBackground);
           layerManager.paint(g,0,0);
           spriteRole.setPosition(currentX,currentY);
           spriteRole.paint(g);
           g.setColor(255,255,255);
           g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM));
           g.drawString("Life:"+gameLifeValueInt,110,0,Graphics.RIGHT|Graphics.TOP);
           if(gameLifeValueInt<=0){
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE));
            g.drawString("In forest you ...",150,80,Graphics.RIGHT|Graphics.TOP);
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_SMALL));
            g.drawString("PLEASE RESTART",170,100,Graphics.RIGHT|Graphics.TOP);
           }
           else if(gameLifeValueInt>=1&&firstGate == 100){
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE));
            g.drawString("you do it",160,80,Graphics.RIGHT|Graphics.TOP);
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL));
            g.drawString("MISSION COMPLETE",170,100,Graphics.RIGHT|Graphics.TOP);
           }
           flushGraphics();
            }
            private TiledLayer initBackground() throws Exception{
             for(int i = 0; i < map.length; i ++){
              int column = i % 12;
              int row = (i - column)/12;
              tiledLayer.setCell(column,row,map[i]);
             }
             return tiledLayer;
            }
          }
          至于地圖,請(qǐng)大家自己看著程序自己隨意構(gòu)思一個(gè)好了。我沒(méi)有在這里寫入地圖,呵呵!程序已經(jīng)編譯通過(guò)!

          posted @ 2007-04-25 06:32 香蕈閣 閱讀(513) | 評(píng)論 (0)編輯 收藏

          2010年11月6日 #

          一下為實(shí)現(xiàn)“走馬燈”方式文字的代碼

          <script language="JavaScript">
             var MESSAGE  =   "  歡迎訪問(wèn),謝謝!    "
             var POSITION = 150
             var DELAY    = 10
             var scroll = new statusMessageObject()
           function statusMessageObject(p,d) {
            this.msg = MESSAGE
            this.out = " "
            this.pos = POSITION
            this.delay = DELAY
            this.i     = 0
            this.reset = clearMessage}
          function clearMessage() {
            this.pos = POSITION}
          function scroller() {
            for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++) {
              scroll.out += " "}
            if (scroll.pos >= 0)
             scroll.out += scroll.msg
            else scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length)
            window.status = scroll.out
            scroll.out = " "
            scroll.pos--
            if (scroll.pos < -(scroll.msg.length)) {
             scroll.reset()}
            setTimeout ('scroller()',scroll.delay)}
          function snapIn(jumpSpaces,position) {
            var msg = scroll.msg
            var out = ""
            for (var i=0; i<position; i++)
              {out += msg.charAt(i)}
            for (i=1;i<jumpSpaces;i++)
              {out += " "}
            out += msg.charAt(position)
            window.status = out
            if (jumpSpaces <= 1) {
              position++
              if (msg.charAt(position) == ' ')
                {position++ }
              jumpSpaces = 100-position
            } else if (jumpSpaces >  3)
                 {jumpSpaces *= .75}
            else
              {jumpSpaces--}
            if (position != msg.length) {
              var cmd = "snapIn(" + jumpSpaces + "," + position + ")";
              scrollID = window.setTimeout(cmd,scroll.delay);
            } else {    window.status=""
              jumpSpaces=0
              position=0
              cmd = "snapIn(" + jumpSpaces + "," + position + ")";
              scrollID = window.setTimeout(cmd,scroll.delay);
              return false }
            return true}
          snapIn(100,0);
          </script>

          posted @ 2010-11-06 08:57 香蕈閣 閱讀(254) | 評(píng)論 (0)編輯 收藏

          2008年9月15日 #

          javabean由三部份組成

          (1)屬性(properties)
          JAVABEAN提供了高層次的屬性概念,屬性在JAVABEAN中不只是傳統(tǒng)的面向?qū)ο蟮母拍罾锏膶傩裕瑫r(shí)還得到了屬性讀取和屬性寫入的API支持。屬性值可以通過(guò)調(diào)用適當(dāng)?shù)腂EAN方法進(jìn)行。比如,可能BEAN有一個(gè)名字屬性,這個(gè)屬性的值可能需要調(diào)用String getName()方法讀取,而寫入屬性值可能要需要調(diào)用void setName(String str)的方法。
          每個(gè)JAVABEAN屬性通常都應(yīng)該遵循簡(jiǎn)單的方法命名規(guī)則,這樣應(yīng)用程序構(gòu)造器工具和最終用戶才能找到JAVABEAN提供的屬性,然后查詢或修改屬性值,對(duì)bean進(jìn)行操作。JAVABEAN還可以對(duì)屬性值的改變作出及時(shí)的反應(yīng)。比如一個(gè)顯示當(dāng)前時(shí)間的JAVABEAN,如果改變時(shí)鐘的時(shí)區(qū)屬性,則時(shí)鐘立即重畫,顯示當(dāng)前指定時(shí)區(qū)的時(shí)間。
          (2)方法(method)
          JAVABEAN中的方法就是通常的JAVA方法,它可以從其它組件或在腳本環(huán)境中調(diào)用。默認(rèn)情況下,所有BEAN的公有方法都可以被外部調(diào)用,但BEAN一般只會(huì)引出其公有方法的一個(gè)子集。
          由于JAVABEAN本身是JAVA對(duì)象,調(diào)用這個(gè)對(duì)象的方法是與其交互作用的唯一途徑。公開BEAN方法在BEAN操作中降為輔助地位,國(guó)為兩個(gè)高級(jí)BEAN特性--屬性的事件是與BEAN交互的最好方式。
          因?yàn)锽EAN可以提供要讓客戶使用的public方法,但應(yīng)當(dāng)認(rèn)識(shí)到,BEAN設(shè)計(jì)人員希望看到絕大部分BEAN的功能反映在屬性和事件中,而不是在人工調(diào)用和各個(gè)方法中。
          (3)事件(event)
          BEAN與其它軟件組件交流信息的主要方式是發(fā)送和接受事件。我們可以將BEAN的事件支持功能看作是集成電路中的輸入輸出引腳:工程師將引腳連接在一起組成系統(tǒng),讓組件進(jìn)行通訊。有些引腳用于輸入,有些引腳用于輸出,相當(dāng)于事件模型中的心頭事件和接收事件。
          事件為JAVABEAN組件提供了一種 發(fā)送通知給其它組件的方法。在AWT事件模型中,一個(gè)事件源可以注冊(cè)事件監(jiān)聽器對(duì)象。當(dāng)事件源檢測(cè)到發(fā)生了某種事件時(shí),它將調(diào)用事件監(jiān)聽器對(duì)象中的一個(gè)適當(dāng)?shù)氖录幚矸椒▉?lái)處理這個(gè)事件。

          posted @ 2008-09-15 13:25 香蕈閣 閱讀(1238) | 評(píng)論 (0)編輯 收藏

          JAVABEAN定義

          JAVABENA也是一種獨(dú)立于平臺(tái)和結(jié)構(gòu)的應(yīng)用程序編程接口(API).
          就好像童年時(shí)玩的積木,把用組件搭起來(lái)的軟件可以理解成用積木搭的形狀不同的作品.因?yàn)榻M件是可重用的,所以肯定是經(jīng)過(guò)很多應(yīng)用程序的測(cè)試.
          JAVABEAN的定義:JAVABEAN是可復(fù)用的平臺(tái)獨(dú)立的軟件組件,開發(fā)者可以在軟件構(gòu)造器工具中對(duì)其直接進(jìn)行可視化操作. 定義中"軟件構(gòu)造器"可以是WEB頁(yè)面構(gòu)造器,可視化應(yīng)用程序構(gòu)造器,GUI設(shè)計(jì)構(gòu)造器或服務(wù)器應(yīng)用程序構(gòu)造器.而JAVABEAN可以是簡(jiǎn)單的GUI要素,如按鈕和滾動(dòng)條;也可以是復(fù)雜的可視化軟件組件,如數(shù)據(jù)庫(kù)視圖.而JAVABEAN是沒(méi)有GUI表現(xiàn)形式的,但這些JAVABEAN仍然可以使用應(yīng)用程序構(gòu)造器可視化地進(jìn)行組合,比如JBuilder上的很多控件其實(shí)也是沒(méi)有GUI形式的,但是你仍然可以拖放它們以在你的應(yīng)用程序里生成相應(yīng)的代碼.一個(gè)JAVABEAN和一個(gè)JAVA APPLET很相似,是一個(gè)非常簡(jiǎn)單的遵循某種嚴(yán)格協(xié)議的JAVA類.

          posted @ 2008-09-15 12:40 香蕈閣 閱讀(546) | 評(píng)論 (0)編輯 收藏

          JAVABEAN學(xué)習(xí)筆記

          源自"清華大學(xué)網(wǎng)絡(luò)系課程",只是本人在閱讀時(shí)粗做的筆記

          posted @ 2008-09-15 12:10 香蕈閣 閱讀(195) | 評(píng)論 (0)編輯 收藏

          2007年5月11日 #

          java awt 圖形用戶界面

          java.awt提供了基于java程序的GUI設(shè)計(jì)工具,主要包括三個(gè)概念:
          Component——組件
          Conainer——容器
          LayoutManager——布局管理器


          類java.awt.Component是許多組件類的父類,Component類中封裝了組件通用的方法和屬性,如圖形的組件對(duì)象、大小、顯示位置、前景色和背景色、邊界、可見性等。相應(yīng)的成員方法包括:
          getComponentAt(intx,inty)
          getFont()
          getForeground()
          getName()
          getSize()
          paint(Graphics g)
          rapaint()
          update()
          setVisible(blooean b)
          setSize(Dimension d)
          setName(String name)等
          Container也是一個(gè)類,實(shí)際上是Component的子類,其本身具有組件的性質(zhì),但是它的主要功能是容納其它組件和容器。
          LayoutManager是在需要對(duì)某個(gè)組件進(jìn)行定位或判斷其大小尺寸時(shí),就會(huì)調(diào)用其對(duì)應(yīng)的布局管理器。


          注意:
          1.如果試圖使用java語(yǔ)言提供的setLocation(),setSize(),setBounds()等方法,則都會(huì)被布局管理器覆蓋。
          2.如果要自己設(shè)置大小和位置,應(yīng)取消布局管理器,方法為:
          setLayout(null)

          posted @ 2007-05-11 17:30 香蕈閣 閱讀(226) | 評(píng)論 (0)編輯 收藏

          2007年4月25日 #

          此J2ME程序已經(jīng)完善,貼出來(lái)大家看看(可惜我沒(méi)能及時(shí)做注釋,還請(qǐng)大家見諒)

          這個(gè)是主文件(后面的是執(zhí)行的操作文件):
          import javax.microedition.midlet.*;
          import javax.microedition.lcdui.*;

          public class LostInForest extends MIDlet implements CommandListener{
           
           private Display display;
           private Canvas canvas;
           private Command exitCmd;
           MenuScreen menuScreen = new MenuScreen();
           MyGameCanvas gameCanvas = new MyGameCanvas();
           
           private Command exitGame;
           Alert aAlert = new Alert("Game Method","Login the game,point up,down,left,right contron",null,AlertType.INFO);
           Alert bAlert = new Alert("Maker","our",null,AlertType.INFO);
           
           public LostInForest(){
            exitCmd = new Command("exit",Command.EXIT,2);
            exitGame = new Command("Exit Game",Command.EXIT,1);
            aAlert.setTimeout(10000);
            bAlert.setTimeout(10000);
            aAlert.addCommand(exitCmd);
            bAlert.addCommand(exitCmd);


            gameCanvas.addCommand(exitGame);
            gameCanvas.setCommandListener(this);
            aAlert.setCommandListener(this);
            bAlert.setCommandListener(this);
           }
           public void startApp() throws MIDletStateChangeException{
            canvas = new MenuScreen();
            display = Display.getDisplay(this);
            display.setCurrent(canvas);
           }
           public void pauseApp(){}
           public void destroyApp(boolean b){}
           public void commandAction(Command cmd,Displayable dis){
            if(cmd == exitCmd){
             display.setCurrent(menuScreen);
            }
            else if(cmd == exitGame){
             System.gc();
             destroyApp(false);
             notifyDestroyed();
            }
           }
           class MenuScreen extends Canvas implements Runnable{
            final Font lowFont = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
            final Font highFont = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE);
            final int lowColor = 0x000000AA;
            final int highColor = 0x00FF0000;
            final int highBGColor = 0x00AAAAAA;
            int width;
            int height;
            int startHeight;
            int menuHeight;
            final int spacing = highFont.getHeight()/2;
            final String[] mainMenu = {"Start Game","Game Method","Worker","Exit"};
            int menuIdx;
            Thread menuThread;
            
            public MenuScreen(){
             width = getWidth();
             height = getHeight();
             menuHeight = (highFont.getHeight() * mainMenu.length)+((mainMenu.length-1)*spacing);
             startHeight = (height - menuHeight)/2+4;
             menuIdx = 0;
             menuThread = new Thread(this);
             menuThread.start();
            }
            public void run(){
             while(true){
              repaint();
             }
            }
            public void paint(Graphics g){
             g.setColor(0x00FFFF00);
             g.fillRect(0,0,width,height);
             
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             Font label1 = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE);
             g.drawString("LostInForest",62,label1.getHeight()/2,Graphics.TOP|Graphics.LEFT);
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             g.drawString("LostInForest",0,24,Graphics.TOP|Graphics.LEFT);
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             g.drawString("Copyright@2007 SZPT",25,145,Graphics.LEFT|Graphics.TOP);
             g.setColor(00,00,00);
             g.setFont(Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_LARGE));
             g.drawString("All Rights Reserved.",30,160,Graphics.LEFT|Graphics.TOP);
             
             for(int i = 0;i<mainMenu.length;i++){
              if(i == menuIdx){
               g.setColor(highBGColor);
               g.fillRect(0,startHeight + (i*highFont.getHeight())+spacing,width,highFont.getHeight());
               g.setFont(highFont);
               g.setColor(highColor);
               g.drawString(mainMenu[i],(width - highFont.stringWidth(mainMenu[i]))/2,startHeight+(i*highFont.getHeight())+spacing,20); 
              }
              else{
             g.setFont(lowFont);
             g.setColor(lowColor);
             g.drawString(mainMenu[i],(width - highFont.stringWidth(mainMenu[i]))/2,startHeight+(i*highFont.getHeight())+spacing,20);
                    }
             }
            }
            protected void keyPressed(int code){
             if(getGameAction(code) == Canvas.UP&&menuIdx - 1 >= 0){
              menuIdx--;
             }
             else if(getGameAction(code) == Canvas.DOWN&&menuIdx + 1 < mainMenu.length){
              menuIdx ++;
             }
             if(getGameAction(code) == Canvas.FIRE){
              if(mainMenu[menuIdx] == "Start Game"){
               gameCanvas.start();
               display.setCurrent(gameCanvas);
               }
              else if(mainMenu[menuIdx] == "Game Method"){
               display.setCurrent(aAlert);
              }
              else if(mainMenu[menuIdx] == "Maker"){
               display.setCurrent(bAlert);
              }
              else if(mainMenu[menuIdx] == "Exit"){
               notifyDestroyed();
              }
             }
            } 
           }
          }
          這個(gè)是主操作文件:
          import javax.microedition.lcdui.*;
          import javax.microedition.lcdui.game.*;
          import javax.microedition.rms.*;

          public class MyGameCanvas extends GameCanvas implements Runnable{
           private boolean isPlay;
           private long delay;
           private int currentX,currentY;
           private int width;
           private int height;
           Graphics g;
           public Display display;
           Image image = null;
           Image tileImages = null;
           private Sprite spriteRole;
           private static int INDEX_OF_UP = 0;
           private static int INDEX_OF_DOWN = 1;
           private static int INDEX_OF_LEFT = 3;
           private static int INDEX_OF_RIGHT = 2;
           private TiledLayer tiledBackground;
           private TiledLayer tiledLayer = null;
           private LayerManager layerManager;
           private RecordStore rs = null;
           private int gameLifeValueInt = 3;
           private String gameLifeValueString = null;
           private int firstGate = 0;
           private int[] map = {
           };
           
           public MyGameCanvas(){
            super(true);
            width = getWidth() - 20;
            height = getHeight() - 17;
            currentX = 160;
            currentY = 160;
            delay = 20;
            g = getGraphics();
            try{
             image = Image.createImage("/player.png");
             spriteRole = new Sprite(image,16,16);
             tileImages = Image.createImage("/tiles.png");
             tiledLayer = new TiledLayer(12,12,tileImages,16,16);
             tiledBackground = initBackground();
             layerManager = new LayerManager();
             layerManager.append(tiledBackground);
             layerManager.append(spriteRole);
             IntToString();
             createNewDB();
             setRecordToDB(1,gameLifeValueString,0,1);
            }
            catch(Exception e){
             e.printStackTrace();
            }
           }
           public void start(){
            isPlay = true;
            Thread t = new Thread(this);
            t.start();
           }
           public void stop(){
            isPlay = false;
           }
           public void run(){
            while(isPlay){
             input();
             drawScreen(g);
             try{
              Thread.sleep(delay);
             }
             catch(InterruptedException ie){}
            }
           }
           private void IntToString(){
            gameLifeValueString = gameLifeValueInt + "";
           }
           private void createNewDB(){
            try{
             rs = RecordStore.openRecordStore("GameDB",true);
            }
            catch(RecordStoreNotFoundException rsnfe){}
            catch(RecordStoreFullException rsfe){}
            catch(RecordStoreException rse){}
           }
           private void addRecordToDB(String str){
            byte rec[] = str.getBytes();
            try{
             rs.addRecord(rec,0,rec.length);
            }
            catch(RecordStoreFullException rse){}
            catch(RecordStoreException rse){}
           }
           private String getRecordFromDB(){
            byte data[] = new byte[5];
            int dataLength = 0;
            try{
             dataLength = rs.getRecord(1,data,0);
            }
            catch(RecordStoreException rse){}
            return new String(data,0,dataLength);
           }
           private void setRecordToDB(int recordID,String str,int offset,int len){
            try{
             byte data[] = str.getBytes();
             rs.setRecord(recordID,data,offset,len);
            }
            catch(RecordStoreException rse){}
           }
           private void input(){
            int keyStates = getKeyStates();
            try{
             if((keyStates&LEFT_PRESSED)!=0&&gameLifeValueInt > 0){
              int tempX = Math.max(0,currentX - 16);
              int tempPoint = tempX/16+currentY*12/16;
              if(map[tempPoint]==1){
               currentX = tempX;
              }
              else if(map[tempPoint]==5){
               currentX = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentX  = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_LEFT);
             }
            else if((keyStates&RIGHT_PRESSED)!=0&&gameLifeValueInt>0){
             int tempX = Math.min(width,currentX + 16);
             int tempPoint = tempX/16+currentY*12/16;
              if(map[tempPoint]==1){
               currentX = tempX;
              }
              else if(map[tempPoint]==5){
               currentX = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentX  = tempX;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_RIGHT);
            }
            else if((keyStates&UP_PRESSED)!=0&&gameLifeValueInt > 0){
             int tempY = Math.max(0,currentY - 16);
             int tempPoint = currentX/16+tempY*12/16;
              if(map[tempPoint]==1){
               currentY = tempY;
              }
              else if(map[tempPoint]==5){
               currentY = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentY = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }   
              else if(map[tempPoint]==2){
               currentY  = tempY;
               try{
                firstGate = 100;
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_UP);
            }
            else if((keyStates&DOWN_PRESSED)!=0&&gameLifeValueInt>0){
             if(currentY + 10<height){
             int tempY = Math.min(height,currentY + 16);
             int tempPoint = currentX/16+tempY*12/16;
              if(map[tempPoint]==1){
               currentY = tempY;
              }
              else if(map[tempPoint]==5){
               currentY = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt--;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              else if(map[tempPoint]==6){
               currentY  = tempY;
               map[tempPoint] = 1;
               try{
                String temp = getRecordFromDB();
                gameLifeValueInt = Integer.parseInt(temp);
                gameLifeValueInt++;
                IntToString();
                setRecordToDB(1,gameLifeValueString,0,1);
                tiledBackground = initBackground();
               }
               catch(Exception e){}
              }
              spriteRole.setFrame(INDEX_OF_DOWN);
             }
            }
             }
           catch(ArrayIndexOutOfBoundsException e){}
           }
           
           public void drawScreen(Graphics g){
           g.setColor(0x00FFFFFF);
           g.fillRect(22,22,getWidth(),getHeight());
           layerManager.append(tiledBackground);
           layerManager.paint(g,0,0);
           spriteRole.setPosition(currentX,currentY);
           spriteRole.paint(g);
           g.setColor(255,255,255);
           g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_MEDIUM));
           g.drawString("Life:"+gameLifeValueInt,110,0,Graphics.RIGHT|Graphics.TOP);
           if(gameLifeValueInt<=0){
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE));
            g.drawString("In forest you ...",150,80,Graphics.RIGHT|Graphics.TOP);
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_SMALL));
            g.drawString("PLEASE RESTART",170,100,Graphics.RIGHT|Graphics.TOP);
           }
           else if(gameLifeValueInt>=1&&firstGate == 100){
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,Font.SIZE_LARGE));
            g.drawString("you do it",160,80,Graphics.RIGHT|Graphics.TOP);
            g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL));
            g.drawString("MISSION COMPLETE",170,100,Graphics.RIGHT|Graphics.TOP);
           }
           flushGraphics();
            }
            private TiledLayer initBackground() throws Exception{
             for(int i = 0; i < map.length; i ++){
              int column = i % 12;
              int row = (i - column)/12;
              tiledLayer.setCell(column,row,map[i]);
             }
             return tiledLayer;
            }
          }
          至于地圖,請(qǐng)大家自己看著程序自己隨意構(gòu)思一個(gè)好了。我沒(méi)有在這里寫入地圖,呵呵!程序已經(jīng)編譯通過(guò)!

          posted @ 2007-04-25 06:32 香蕈閣 閱讀(513) | 評(píng)論 (0)編輯 收藏

          2006年5月16日 #

          一個(gè)UI窗體的設(shè)計(jì)---暫時(shí)還沒(méi)有添加功能的

          /*
          ?* universtay.java
          ?*
          ?* Created on 2006年5月14日, 下午10:02
          ?*/

          package Applet;

          /**
          ?*
          ?* @author? h
          ?*/
          public class universtay extends javax.swing.JApplet {
          ???
          ??? /** Initializes the applet universtay */
          ??? public void init() {
          ??????? try {
          ??????????? java.awt.EventQueue.invokeAndWait(new Runnable() {
          ??????????????? public void run() {
          ??????????????????? initComponents();
          ??????????????? }
          ??????????? });
          ??????? } catch (Exception ex) {
          ??????????? ex.printStackTrace();
          ??????? }
          ??? }
          ???
          ??? /** This method is called from within the init() method to
          ???? * initialize the form.
          ???? * WARNING: Do NOT modify this code. The content of this method is
          ???? * always regenerated by the Form Editor.
          ???? */
          ??? // <editor-fold defaultstate="collapsed" desc=" 生成的代碼 ">?????????????????????????
          ??? private void initComponents() {
          ??????? label1 = new java.awt.Label();
          ??????? textField1 = new java.awt.TextField();
          ??????? button1 = new java.awt.Button();
          ??????? label2 = new java.awt.Label();
          ??????? choice1 = new java.awt.Choice();
          ??????? checkbox1 = new java.awt.Checkbox();
          ??????? checkbox2 = new java.awt.Checkbox();
          ??????? checkbox3 = new java.awt.Checkbox();
          ??????? label3 = new java.awt.Label();
          ??????? choice2 = new java.awt.Choice();
          ??????? button2 = new java.awt.Button();
          ??????? label4 = new java.awt.Label();
          ??????? textField2 = new java.awt.TextField();
          ??????? label5 = new java.awt.Label();
          ??????? textField3 = new java.awt.TextField();
          ??????? label6 = new java.awt.Label();
          ??????? textField4 = new java.awt.TextField();
          ??????? textArea1 = new java.awt.TextArea();
          ??????? jRadioButton1 = new javax.swing.JRadioButton();
          ??????? jRadioButton2 = new javax.swing.JRadioButton();
          ??????? jRadioButton3 = new javax.swing.JRadioButton();
          ??????? jSpinner1 = new javax.swing.JSpinner();
          ??????? jPasswordField1 = new javax.swing.JPasswordField();

          ??????? label1.setText("label1");

          ??????? textField1.setText("textField1");

          ??????? button1.setLabel("button1");

          ??????? label2.setText("label2");

          ??????? checkbox1.setLabel("checkbox1");

          ??????? checkbox2.setLabel("checkbox2");

          ??????? checkbox3.setLabel("checkbox3");

          ??????? label3.setText("label3");

          ??????? button2.setLabel("button2");

          ??????? label4.setText("label4");

          ??????? textField2.setText("textField2");

          ??????? label5.setText("label5");

          ??????? textField3.setText("textField3");

          ??????? label6.setText("label6");

          ??????? textField4.setText("textField4");

          ??????? jRadioButton1.setText("jRadioButton1");
          ??????? jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
          ??????? jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));

          ??????? jRadioButton2.setText("jRadioButton2");
          ??????? jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
          ??????? jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));

          ??????? jRadioButton3.setText("jRadioButton3");
          ??????? jRadioButton3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
          ??????? jRadioButton3.setMargin(new java.awt.Insets(0, 0, 0, 0));

          ??????? jPasswordField1.setText("jPasswordField1");

          ??????? org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
          ??????? getContentPane().setLayout(layout);
          ??????? layout.setHorizontalGroup(
          ??????????? layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????? .add(layout.createSequentialGroup()
          ??????????????? .addContainerGap()
          ??????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????? .add(layout.createSequentialGroup()
          ??????????????????????? .add(label6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????? .add(textField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
          ??????????????????????? .addContainerGap())
          ??????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
          ??????????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????????????? .add(layout.createSequentialGroup()
          ??????????????????????????????? .add(label1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 48, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????????????? .add(textField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
          ??????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????????????? .add(label2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 42, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????????????? .add(choice1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
          ??????????????????????????? .add(layout.createSequentialGroup()
          ??????????????????????????????? .add(checkbox3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????????????? .add(jRadioButton3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
          ??????????????????????????????? .add(16, 16, 16)
          ??????????????????????????????? .add(label5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????????????? .add(textField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 211, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
          ??????????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
          ??????????????????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????????????????????? .add(layout.createSequentialGroup()
          ??????????????????????????????????????? .add(checkbox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????????????????????? .add(jRadioButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
          ??????????????????????????????????????? .add(16, 16, 16)
          ??????????????????????????????????????? .add(label4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
          ??????????????????????????????????? .add(layout.createSequentialGroup()
          ??????????????????????????????????????? .add(checkbox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????????????????????? .add(jRadioButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????????????????????????? .add(16, 16, 16)
          ??????????????????????????????????????? .add(label3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????????????????? .add(12, 12, 12)))
          ??????????????????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, choice2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
          ??????????????????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, textField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE))))
          ??????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????????????? .add(button1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
          ??????????????????????????? .add(button2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
          ??????????????????????????? .add(jSpinner1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
          ??????????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, jPasswordField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))
          ??????????????????????? .addContainerGap())))
          ??????????? .add(layout.createSequentialGroup()
          ??????????????? .add(textArea1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 571, Short.MAX_VALUE)
          ??????????????? .addContainerGap())
          ??????? );

          ??????? layout.linkSize(new java.awt.Component[] {label1, label2}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

          ??????? layout.setVerticalGroup(
          ??????????? layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????? .add(layout.createSequentialGroup()
          ??????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????? .add(choice1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????? .add(label2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
          ??????????????????? .add(textField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????? .add(label1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
          ??????????????????? .add(button1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
          ??????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????? .add(button2, 0, 0, Short.MAX_VALUE)
          ??????????????????? .add(choice2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
          ??????????????????????? .add(checkbox1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, jRadioButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
          ??????????????????????? .add(label3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
          ??????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????? .add(layout.createSequentialGroup()
          ??????????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
          ??????????????????????????? .add(textField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, label4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, jRadioButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????????? .add(checkbox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
          ??????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
          ??????????????????????????? .add(textField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
          ??????????????????????????????? .add(checkbox3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, label5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          ??????????????????????????????? .add(jRadioButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
          ??????????????????? .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
          ??????????????????????? .add(jSpinner1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 10, Short.MAX_VALUE)
          ??????????????????????? .add(jPasswordField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
          ??????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????? .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
          ??????????????????? .add(label6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
          ??????????????????? .add(textField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
          ??????????????? .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
          ??????????????? .add(textArea1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 142, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
          ??????? );

          ??????? layout.linkSize(new java.awt.Component[] {button1, textField4}, org.jdesktop.layout.GroupLayout.VERTICAL);

          ??????? layout.linkSize(new java.awt.Component[] {choice1, choice2, textField1, textField2, textField3}, org.jdesktop.layout.GroupLayout.VERTICAL);

          ??? }// </editor-fold>???????????????????????
          ???
          ???
          ??? // 變量聲明 - 不進(jìn)行修改????????????????????
          ??? private java.awt.Button button1;
          ??? private java.awt.Button button2;
          ??? private java.awt.Checkbox checkbox1;
          ??? private java.awt.Checkbox checkbox2;
          ??? private java.awt.Checkbox checkbox3;
          ??? private java.awt.Choice choice1;
          ??? private java.awt.Choice choice2;
          ??? private javax.swing.JPasswordField jPasswordField1;
          ??? private javax.swing.JRadioButton jRadioButton1;
          ??? private javax.swing.JRadioButton jRadioButton2;
          ??? private javax.swing.JRadioButton jRadioButton3;
          ??? private javax.swing.JSpinner jSpinner1;
          ??? private java.awt.Label label1;
          ??? private java.awt.Label label2;
          ??? private java.awt.Label label3;
          ??? private java.awt.Label label4;
          ??? private java.awt.Label label5;
          ??? private java.awt.Label label6;
          ??? private java.awt.TextArea textArea1;
          ??? private java.awt.TextField textField1;
          ??? private java.awt.TextField textField2;
          ??? private java.awt.TextField textField3;
          ??? private java.awt.TextField textField4;
          ??? // 變量聲明結(jié)束??????????????????
          ???
          }


          已經(jīng)通過(guò)運(yùn)行.........功能還有待添加

          posted @ 2006-05-16 18:49 香蕈閣 閱讀(519) | 評(píng)論 (1)編輯 收藏

          僅列出標(biāo)題  
          主站蜘蛛池模板: 西平县| 墨竹工卡县| 乌审旗| 沙湾县| 诸城市| 松原市| 陵水| 康平县| 维西| 大足县| 镇原县| 吉安县| 台东市| 金寨县| 黎川县| 三门峡市| 甘泉县| 铁力市| 濮阳市| 楚雄市| 永靖县| 长治市| 鸡西市| 平湖市| 宜春市| 襄汾县| 长治县| 新兴县| 梁山县| 呼和浩特市| 灵璧县| 长春市| 孟村| 仪征市| 澜沧| 农安县| 长宁区| 蓝山县| 淳化县| 本溪| 丰台区|