中国象棋源代码Java程序.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《中国象棋源代码Java程序.doc》由会员分享,可在线阅读,更多相关《中国象棋源代码Java程序.doc(53页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import java.io.*;public class Chesspublic static void main(String args)new ChessMainFrame(中国象棋:观棋不语真君子,棋死无悔大丈夫);class ChessMainFrame extends JFrame implements ActionListener,MouseListener,Runnable/玩家JLabel play = new
2、JLabel32;/棋盘JLabel image;/窗格Container con;/工具栏JToolBar jmain;/重新开始JButton anew;/悔棋JButton repent;/退出JButton exit;/当前信息JLabel text;/保存当前操作Vector Var;/规则类对象(使于调用方法)ChessRule rule;/* 单击棋子* chessManClick = true 闪烁棋子 并给线程响应* chessManClick = false 吃棋子 停止闪烁 并给线程响应*/boolean chessManClick;/* 控制玩家走棋* chessPla
3、yClick=1 黑棋走棋* chessPlayClick=2 红棋走棋 默认红棋* chessPlayClick=3 双方都不能走棋*/int chessPlayClick=2;/控制棋子闪烁的线程Thread tmain;/把第一次的单击棋子给线程响应static int Man,i;ChessMainFrame()new ChessMainFrame(中国象棋);/* 构造函数* 初始化图形用户界面*/ChessMainFrame(String Title)/获行客格引用con = this.getContentPane();con.setLayout(null);/实例化规则类rule
4、 = new ChessRule();Var = new Vector();/创建工具栏jmain = new JToolBar();text = new JLabel(欢迎使用象棋对弈系统);/当鼠标放上显示信息text.setToolTipText(信息提示);anew = new JButton( 新 游 戏 );anew.setToolTipText(重新开始新的一局);exit = new JButton( 退 出 );exit.setToolTipText(退出象棋程序程序);repent = new JButton( 悔 棋 );repent.setToolTipText(返回到
5、上次走棋的位置);/把组件添加到工具栏jmain.setLayout(new GridLayout(0,4);jmain.add(anew);jmain.add(repent);jmain.add(exit);jmain.add(text);jmain.setBounds(0,0,558,30);con.add(jmain);/添加棋子标签drawChessMan();/注册按扭监听anew.addActionListener(this);repent.addActionListener(this);exit.addActionListener(this);/注册棋子移动监听for (int
6、i=0;i screenSize.height)frameSize.height = screenSize.height;if (frameSize.width screenSize.width)frameSize.width = screenSize.width;this.setLocation(screenSize.width - frameSize.width) / 2 - 280 ,(screenSize.height - frameSize.height ) / 2 - 350);/设置this.setIconImage(new ImageIcon(image红将.GIF).getI
7、mage();this.setResizable(false);this.setTitle(Title);this.setSize(558,670);this.show();/* 添加棋子方法*/public void drawChessMan()/流程控制int i,k;/图标Icon in;/黑色棋子/车in = new ImageIcon(image黑车.GIF);for (i=0,k=24;i2;i+,k+=456)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName(车1);/马in = new ImageI
8、con(image黑马.GIF);for (i=4,k=81;i6;i+,k+=342)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName(马1);/相in = new ImageIcon(image黑象.GIF);for (i=8,k=138;i10;i+,k+=228)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName(象1);/士in = new ImageIcon(image黑士.GIF);for (i=12,k=195;i14;i
9、+,k+=114)playi = new JLabel(in);playi.setBounds(k,56,55,55);playi.setName(士1);/卒in = new ImageIcon(image黑卒.GIF);for (i=16,k=24;i21;i+,k+=114)playi = new JLabel(in);playi.setBounds(k,227,55,55);playi.setName(卒1 + i);/炮in = new ImageIcon(image黑炮.GIF);for (i=26,k=81;i28;i+,k+=342)playi = new JLabel(in)
10、;playi.setBounds(k,170,55,55);playi.setName(炮1 + i);/将in = new ImageIcon(image黑将.GIF);play30 = new JLabel(in);play30.setBounds(252,56,55,55);play30.setName(将1);/红色棋子/车in = new ImageIcon(image红车.GIF);for (i=2,k=24;i4;i+,k+=456)playi = new JLabel(in);playi.setBounds(k,569,55,55);playi.setName(车2);/马in
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 中国象棋 源代码 java 程序
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内