josn1984

常用链接

统计

最新评论

置顶随笔 #

[置顶]此J2ME程序已经完善,贴出来大家看看(可惜我没能及时做注释,还请大家见谅)

这个是主文件(后面的是执行的操作文件):
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();
    }
   }
  } 
 }
}
这个是主操作文件:
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;
  }
}
至于地图,请大家自己看着程序自己随意构思一个好了。我没有在这里写入地图,呵呵!程序已经编译通过!

posted @ 2007-04-25 06:32 香蕈阁 阅读(505) | 评论 (0)编辑 收藏

2010年11月6日 #

一下为实现“走马灯”方式文字的代码

<script language="JavaScript">
   var MESSAGE  =   "  欢迎访问,谢谢!    "
   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 香蕈阁 阅读(245) | 评论 (0)编辑 收藏

2008年9月15日 #

javabean由三部份组成

(1)属性(properties)
JAVABEAN提供了高层次的属性概念,属性在JAVABEAN中不只是传统的面向对象的概念里的属性,它同时还得到了属性读取和属性写入的API支持。属性值可以通过调用适当的BEAN方法进行。比如,可能BEAN有一个名字属性,这个属性的值可能需要调用String getName()方法读取,而写入属性值可能要需要调用void setName(String str)的方法。
每个JAVABEAN属性通常都应该遵循简单的方法命名规则,这样应用程序构造器工具和最终用户才能找到JAVABEAN提供的属性,然后查询或修改属性值,对bean进行操作。JAVABEAN还可以对属性值的改变作出及时的反应。比如一个显示当前时间的JAVABEAN,如果改变时钟的时区属性,则时钟立即重画,显示当前指定时区的时间。
(2)方法(method)
JAVABEAN中的方法就是通常的JAVA方法,它可以从其它组件或在脚本环境中调用。默认情况下,所有BEAN的公有方法都可以被外部调用,但BEAN一般只会引出其公有方法的一个子集。
由于JAVABEAN本身是JAVA对象,调用这个对象的方法是与其交互作用的唯一途径。公开BEAN方法在BEAN操作中降为辅助地位,国为两个高级BEAN特性--属性的事件是与BEAN交互的最好方式。
因为BEAN可以提供要让客户使用的public方法,但应当认识到,BEAN设计人员希望看到绝大部分BEAN的功能反映在属性和事件中,而不是在人工调用和各个方法中。
(3)事件(event)
BEAN与其它软件组件交流信息的主要方式是发送和接受事件。我们可以将BEAN的事件支持功能看作是集成电路中的输入输出引脚:工程师将引脚连接在一起组成系统,让组件进行通讯。有些引脚用于输入,有些引脚用于输出,相当于事件模型中的心头事件和接收事件。
事件为JAVABEAN组件提供了一种 发送通知给其它组件的方法。在AWT事件模型中,一个事件源可以注册事件监听器对象。当事件源检测到发生了某种事件时,它将调用事件监听器对象中的一个适当的事件处理方法来处理这个事件。

posted @ 2008-09-15 13:25 香蕈阁 阅读(1232) | 评论 (0)编辑 收藏

JAVABEAN定义

JAVABENA也是一种独立于平台和结构的应用程序编程接口(API).
就好像童年时玩的积木,把用组件搭起来的软件可以理解成用积木搭的形状不同的作品.因为组件是可重用的,所以肯定是经过很多应用程序的测试.
JAVABEAN的定义:JAVABEAN是可复用的平台独立的软件组件,开发者可以在软件构造器工具中对其直接进行可视化操作. 定义中"软件构造器"可以是WEB页面构造器,可视化应用程序构造器,GUI设计构造器或服务器应用程序构造器.而JAVABEAN可以是简单的GUI要素,如按钮和滚动条;也可以是复杂的可视化软件组件,如数据库视图.而JAVABEAN是没有GUI表现形式的,但这些JAVABEAN仍然可以使用应用程序构造器可视化地进行组合,比如JBuilder上的很多控件其实也是没有GUI形式的,但是你仍然可以拖放它们以在你的应用程序里生成相应的代码.一个JAVABEAN和一个JAVA APPLET很相似,是一个非常简单的遵循某种严格协议的JAVA类.

posted @ 2008-09-15 12:40 香蕈阁 阅读(540) | 评论 (0)编辑 收藏

JAVABEAN学习笔记

源自"清华大学网络系课程",只是本人在阅读时粗做的笔记

posted @ 2008-09-15 12:10 香蕈阁 阅读(188) | 评论 (0)编辑 收藏

2007年5月11日 #

java awt 图形用户界面

java.awt提供了基于java程序的GUI设计工具,主要包括三个概念:
Component——组件
Conainer——容器
LayoutManager——布局管理器


类java.awt.Component是许多组件类的父类,Component类中封装了组件通用的方法和属性,如图形的组件对象、大小、显示位置、前景色和背景色、边界、可见性等。相应的成员方法包括:
getComponentAt(intx,inty)
getFont()
getForeground()
getName()
getSize()
paint(Graphics g)
rapaint()
update()
setVisible(blooean b)
setSize(Dimension d)
setName(String name)等
Container也是一个类,实际上是Component的子类,其本身具有组件的性质,但是它的主要功能是容纳其它组件和容器。
LayoutManager是在需要对某个组件进行定位或判断其大小尺寸时,就会调用其对应的布局管理器。


注意:
1.如果试图使用java语言提供的setLocation(),setSize(),setBounds()等方法,则都会被布局管理器覆盖。
2.如果要自己设置大小和位置,应取消布局管理器,方法为:
setLayout(null)

posted @ 2007-05-11 17:30 香蕈阁 阅读(220) | 评论 (0)编辑 收藏

2007年4月25日 #

此J2ME程序已经完善,贴出来大家看看(可惜我没能及时做注释,还请大家见谅)

这个是主文件(后面的是执行的操作文件):
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();
    }
   }
  } 
 }
}
这个是主操作文件:
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;
  }
}
至于地图,请大家自己看着程序自己随意构思一个好了。我没有在这里写入地图,呵呵!程序已经编译通过!

posted @ 2007-04-25 06:32 香蕈阁 阅读(505) | 评论 (0)编辑 收藏

2006年5月16日 #

一个UI窗体的设计---暂时还没有添加功能的

/*
 * 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>                       
   
   
    // 变量声明 - 不进行修改                    
    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;
    // 变量声明结束                  
   
}


已经通过运行.........功能还有待添加

posted @ 2006-05-16 18:49 香蕈阁 阅读(512) | 评论 (1)编辑 收藏

仅列出标题