Chinese chess game realized by Java+Swing

Posted by wdwtest on Tue, 08 Feb 2022 15:07:41 +0100

catalogue

1, System introduction

1. Development environment

2. Technical selection

3. System functions

2, System display

1. Home page

2. Black chess

3. Red flag walk

3, Partial code

ChineseCheseRule.java

4, Other

1. More systems

Java swing system series implementation

Java+JSP system series implementation

Java+Servlet system series implementation

Java+SSM system series implementation

Java+SSH system series implementation

Java+Springboot system series implementation

2. Source code download

3. Operation project

4. Remarks

5. Blogger support

1, System introduction

1. Development environment

Development tool: Eclipse 2021

JDK version: jdk1.0 eight

Mysql version: 8.0.13

2. Technical selection

Java+Swing

3. System functions

Realize the Chinese chess game, start the game, repent chess and exit function.

2, System display

1. Home page

 

2. Black chess

 

3. Red flag walk

3, Partial code

ChineseCheseRule.java

package com.sjsq;

import java.awt.event.MouseEvent;

import javax.swing.JLabel;

/* Class defining Chinese chess rules */
public class ChineseCheseRule {
	/** Pawn movement rules */
	public void armsRule(int Man, JLabel chessMain, MouseEvent me) {
		int boardX = Math.round((float) (me.getX() - 24) / 57) * 57 + 24;
		int boardY = Math.round((float) (me.getY() - 56) / 57) * 57 + 56;
		// Black pawn down
		if (Man < 21) {
			// Move down
			if (boardY - chessMain.getY() == 57 && boardX == chessMain.getX()
					&& boardY <= 569) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(Man));
				chessMain.setBounds(chessMain.getX(), chessMain.getY() + 57,
						55, 55);
			}
			// If you move to the right, you must cross the river
			else if (chessMain.getY() >= 341 && boardY == chessMain.getY()
					&& boardX - chessMain.getX() == 57 && boardX <= 480) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(Man));
				chessMain.setBounds(chessMain.getX() + 57, chessMain.getY(),
						55, 55);
			}
			// To move to the left, you must cross the river
			else if (chessMain.getY() >= 341 && boardY == chessMain.getY()
					&& chessMain.getX() - boardX == 57 && boardX >= 24) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(Man));
				chessMain.setBounds(chessMain.getX() - 57, chessMain.getY(),
						55, 55);
			}
		}
		// Red pawn up
		else {
			// Move up
			if (chessMain.getY() - boardY == 57 && boardX == chessMain.getX()
					&& boardY >= 56) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(Man));
				chessMain.setBounds(chessMain.getX(), chessMain.getY() - 57,
						55, 55);
			}
			// If you move to the right, you must cross the river
			else if (chessMain.getY() <= 284 && boardY == chessMain.getY()
					&& boardX - chessMain.getX() == 57 && boardX <= 480) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(Man));
				chessMain.setBounds(chessMain.getX() + 57, chessMain.getY(),
						55, 55);
			}
			// To move to the left, you must cross the river
			else if (chessMain.getY() <= 284 && boardY == chessMain.getY()
					&& chessMain.getX() - boardX == 57 && boardX >= 24) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(Man));
				chessMain.setBounds(chessMain.getX() - 57, chessMain.getY(),
						55, 55);
			}
		}
	}// End of pawn movement

	/** Rules of pawn eating chess */
	public void armsRule(JLabel chessMain1, JLabel chessMain2) {
		// turn right
		if (chessMain2.getX() - chessMain1.getX() == 57
				&& chessMain1.getY() == chessMain2.getY()
				&& chessMain2.isVisible()
				&& chessMain1.getName().charAt(1) != chessMain2.getName()
						.charAt(1)) {
			// Black chess has to cross the river to eat chess
			if (chessMain1.getName().charAt(1) == '1'
					&& chessMain1.getY() >= 341) {
				ChineseChessMainFrame.list.add(String.valueOf(3));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain1
						.getName().substring(2)));
				ChineseChessMainFrame.list.add(String.valueOf(2));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain2
						.getName().substring(2)));
				chessMain2.setVisible(false);
				chessMain1.setBounds(chessMain2.getX(), chessMain2.getY(), 55,
						55);
			}
			// Red chess has to cross the river to eat chess
			else if (chessMain1.getName().charAt(1) == '2'
					&& chessMain1.getY() <= 284) {
				ChineseChessMainFrame.list.add(String.valueOf(3));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain1
						.getName().substring(2)));
				ChineseChessMainFrame.list.add(String.valueOf(2));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain2
						.getName().substring(2)));
				chessMain2.setVisible(false);
				chessMain1.setBounds(chessMain2.getX(), chessMain2.getY(), 55,
						55);
			}
		}
		// turn left
		else if (chessMain1.getX() - chessMain2.getX() == 57
				&& chessMain1.getY() == chessMain2.getY()
				&& chessMain2.isVisible()
				&& chessMain1.getName().charAt(1) != chessMain2.getName()
						.charAt(1)) {
			// Black chess has to cross the river to eat chess
			if (chessMain1.getName().charAt(1) == '1'
					&& chessMain1.getY() >= 341) {
				ChineseChessMainFrame.list.add(String.valueOf(3));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain1
						.getName().substring(2)));
				ChineseChessMainFrame.list.add(String.valueOf(2));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain2
						.getName().substring(2)));
				chessMain2.setVisible(false);
				chessMain1.setBounds(chessMain2.getX(), chessMain2.getY(), 55,
						55);
			}
			// Red chess has to cross the river to eat chess
			else if (chessMain1.getName().charAt(1) == '2'
					&& chessMain1.getY() <= 284) {
				ChineseChessMainFrame.list.add(String.valueOf(3));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain1
						.getName().substring(2)));
				ChineseChessMainFrame.list.add(String.valueOf(2));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain2
						.getName().substring(2)));
				chessMain2.setVisible(false);
				chessMain1.setBounds(chessMain2.getX(), chessMain2.getY(), 55,
						55);
			}
		}
		// Go up or down
		else if (chessMain1.getX() == chessMain2.getX()
				&& Math.abs(chessMain1.getY() - chessMain2.getY()) == 57
				&& chessMain2.isVisible()
				&& chessMain1.getName().charAt(1) != chessMain2.getName()
						.charAt(1)) {
			// Black chess can only eat chess downward
			if (chessMain1.getName().charAt(1) == '1'
					&& chessMain2.getY() - chessMain1.getY() == 57) {
				ChineseChessMainFrame.list.add(String.valueOf(3));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain1
						.getName().substring(2)));
				ChineseChessMainFrame.list.add(String.valueOf(2));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain2
						.getName().substring(2)));
				chessMain2.setVisible(false);
				chessMain1.setBounds(chessMain2.getX(), chessMain2.getY(), 55,
						55);
			}
			// Red chess can only eat chess upward
			else if (chessMain1.getName().charAt(1) == '2'
					&& chessMain1.getY() - chessMain2.getY() == 57) {
				ChineseChessMainFrame.list.add(String.valueOf(3));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain1.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain1
						.getName().substring(2)));
				ChineseChessMainFrame.list.add(String.valueOf(2));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getX()));
				ChineseChessMainFrame.list
						.add(String.valueOf(chessMain2.getY()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMain2
						.getName().substring(2)));
				chessMain2.setVisible(false);
				chessMain1.setBounds(chessMain2.getX(), chessMain2.getY(), 55,
						55);
			}
		}

	}// End of pawn eating

	/** Gun and vehicle movement rules */
	public void cannonRule(JLabel chessMan, JLabel[] chessman, MouseEvent me) {
		int boardX = Math.round((float) (me.getX() - 24) / 57) * 57 + 24;
		int boardY = Math.round((float) (me.getY() - 56) / 57) * 57 + 56;
		// Is there a piece between the beginning and the end
		int count = 0;
		// Move up and down
		if (chessMan.getX() == boardX && chessMan.getY() != boardY
				&& boardY >= 56 && boardY <= 569) {
			// Find all the pieces on the same vertical line, not including yourself
			for (int j = 0; j < chessman.length; j++) {
				if (chessman[j].getX() == chessMan.getX()
						&& !chessman[j].getName().equals(chessMan.getName())
						&& chessman[j].isVisible()) {
					if ((chessman[j].getY() > chessMan.getY() && chessman[j]
							.getY() < boardY)
							|| (chessman[j].getY() < chessMan.getY() && chessman[j]
									.getY() > boardY)) {
						count++;
						break;
					}
				}

			}
			if (count == 0) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].getName().equals(chessMan.getName())) {
						ChineseChessMainFrame.list.add(String.valueOf(i));
						break;
					}
				}
				chessMan.setBounds(boardX, boardY, 55, 55);
			}
		}
		// Move left and right
		if (chessMan.getY() == boardY && chessMan.getX() != boardX
				&& boardX >= 24 && boardX <= 480) {
			// Find all the pieces on the same horizontal line, not including yourself
			for (int j = 0; j < chessman.length; j++) {
				if (chessman[j].getY() == chessMan.getY()
						&& !chessman[j].getName().equals(chessMan.getName())
						&& chessman[j].isVisible()) {
					if ((chessman[j].getX() > chessMan.getX() && chessman[j]
							.getX() < boardX)
							|| (chessman[j].getX() < chessMan.getX() && chessman[j]
									.getX() > boardX)) {
						count++;
						break;
					}
				}

			}
			if (count == 0) {
				ChineseChessMainFrame.list.add(String.valueOf(1));
				ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
				ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].getName().equals(chessMan.getName())) {
						ChineseChessMainFrame.list.add(String.valueOf(i));
						break;
					}
				}
				chessMan.setBounds(boardX, boardY, 55, 55);
			}
		}
	}// End of gun and vehicle movement method

	/** Rules of eating chess with guns and cars */
	public void cannonRule(int chess, JLabel chessMan, JLabel chessManTake,
			JLabel[] chessman) {

		// Is there a piece between the beginning and the end
		int count = 0;
		if (chessMan.getX() == chessManTake.getX()
				&& chessMan.getY() != chessManTake.getY()) {
			// All the pieces
			for (int i = 0; i < chessman.length; i++) {
				// Find all the pieces on the same vertical line, not including yourself
				if (chessman[i].getX() == chessMan.getX()
						&& !chessman[i].getName().equals(chessMan.getName())
						&& chessman[i].isVisible()) {
					if ((chessman[i].getY() > chessMan.getY() && chessman[i]
							.getY() < chessManTake.getY())
							|| (chessman[i].getY() < chessMan.getY() && chessman[i]
									.getY() > chessManTake.getY())) {
						count++;
					}
				}
			}
		} else if (chessMan.getY() == chessManTake.getY()
				&& chessMan.getX() != chessManTake.getX()) {
			// All the pieces
			for (int i = 0; i < chessman.length; i++) {
				// Find all the pieces on the same horizontal line, not including yourself
				if (chessman[i].getY() == chessMan.getY()
						&& !chessman[i].getName().equals(chessMan.getName())
						&& chessman[i].isVisible()) {
					if ((chessman[i].getX() > chessMan.getX() && chessman[i]
							.getX() < chessManTake.getX())
							|| (chessman[i].getX() < chessMan.getX() && chessman[i]
									.getX() > chessManTake.getX())) {
						count++;
					}
				}
			}
		}
		// There is only one piece between the starting point and the ending point. It is the rule of the gun and you can't eat your own pieces
		if (count == 1
				&& chess == 0
				&& chessMan.getName().charAt(1) != chessManTake.getName()
						.charAt(1)) {
			ChineseChessMainFrame.list.add(String.valueOf(3));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getName()
					.substring(2)));
			ChineseChessMainFrame.list.add(String.valueOf(2));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake
					.getName().substring(2)));
			chessManTake.setVisible(false);
			chessMan.setBounds(chessManTake.getX(), chessManTake.getY(), 55, 55);
		}
		// There is no chess piece between the starting point and the ending point. It is the rule of the car and you can't eat your own chess pieces
		else if (count == 0
				&& chess == 1
				&& chessMan.getName().charAt(1) != chessManTake.getName()
						.charAt(1)) {
			ChineseChessMainFrame.list.add(String.valueOf(3));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getName()
					.substring(2)));
			ChineseChessMainFrame.list.add(String.valueOf(2));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake
					.getName().substring(2)));
			chessManTake.setVisible(false);
			chessMan.setBounds(chessManTake.getX(), chessManTake.getY(), 55, 55);
		}
	}// The method of eating chess with guns and cars ends

	/** Horse movement rule */
	public void horseRule(JLabel chessMan, JLabel[] chessman, MouseEvent me) {
		int boardX = Math.round((float) (me.getX() - 24) / 57) * 57 + 24;
		int boardY = Math.round((float) (me.getY() - 56) / 57) * 57 + 56;
		// Preservation barrier
		int Move = 0;
		if (boardY >= 56 && boardY <= 569 && boardX >= 24 && boardX <= 480) {
			// Move left, top
			if (chessMan.getX() - boardX == 114
					&& chessMan.getY() - boardY == 57) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessMan.getX() - chessman[i].getX() == 57
							&& chessMan.getY() == chessman[i].getY()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Move left and down
			else if (chessMan.getX() - boardX == 114
					&& boardY - chessMan.getY() == 57) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessMan.getX() - chessman[i].getX() == 57
							&& chessMan.getY() == chessman[i].getY()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Move right, top
			else if (boardX - chessMan.getX() == 114
					&& chessMan.getY() - boardY == 57) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].getX() - chessMan.getX() == 57
							&& chessMan.getY() == chessman[i].getY()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Move right, lower
			else if (boardX - chessMan.getX() == 114
					&& boardY - chessMan.getY() == 57) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].getX() - chessMan.getX() == 57
							&& chessMan.getY() == chessman[i].getY()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Move up, left
			else if (chessMan.getX() - boardX == 57
					&& chessMan.getY() - boardY == 114) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessMan.getY() - chessman[i].getY() == 57
							&& chessMan.getX() == chessman[i].getX()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Move up, right
			else if (boardX - chessMan.getX() == 57
					&& chessMan.getY() - boardY == 114) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessMan.getY() - chessman[i].getY() == 57
							&& chessMan.getX() == chessman[i].getX()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Move down, left
			else if (chessMan.getX() - boardX == 57
					&& boardY - chessMan.getY() == 114) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].getY() - chessMan.getY() == 57
							&& chessMan.getX() == chessman[i].getX()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Move down, right
			else if (boardX - chessMan.getX() == 57
					&& boardY - chessMan.getY() == 114) {
				// Are there any other pieces in front
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].getY() - chessMan.getY() == 57
							&& chessMan.getX() == chessman[i].getX()
							&& chessman[i].isVisible()) {
						Move = 1;
						break;
					}
				}
				// You can move the piece
				if (Move == 0) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					for (int i = 0; i < chessman.length; i++) {
						if (chessman[i].getName().equals(chessMan.getName())) {
							ChineseChessMainFrame.list.add(String.valueOf(i));
							break;
						}
					}
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
		}
	}// End of horse movement

	/** Rules of horse eating chess */
	public void horseRule(JLabel chessMan, JLabel chessManTake,
			JLabel[] chessman) {
		// Preservation barrier
		int Move = 0;
		boolean Chess = false;
		// Move left, top
		if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(1)
				&& chessMan.getX() - chessManTake.getX() == 114
				&& chessMan.getY() - chessManTake.getY() == 57) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessMan.getX() - chessman[i].getX() == 57
						&& chessMan.getY() == chessman[i].getY()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// Move left and down
		else if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(
				1)
				&& chessMan.getX() - chessManTake.getX() == 114
				&& chessManTake.getY() - chessMan.getY() == 57) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessMan.getX() - chessman[i].getX() == 57
						&& chessMan.getY() == chessman[i].getY()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// Move right, top
		else if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(
				1)
				&& chessManTake.getX() - chessMan.getX() == 114
				&& chessMan.getY() - chessManTake.getY() == 57) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].getX() - chessMan.getX() == 57
						&& chessMan.getY() == chessman[i].getY()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// Move right, lower
		else if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(
				1)
				&& chessManTake.getX() - chessMan.getX() == 114
				&& chessManTake.getY() - chessMan.getY() == 57) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].getX() - chessMan.getX() == 57
						&& chessMan.getY() == chessman[i].getY()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// Move up, left
		else if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(
				1)
				&& chessMan.getX() - chessManTake.getX() == 57
				&& chessMan.getY() - chessManTake.getY() == 114) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessMan.getY() - chessman[i].getY() == 57
						&& chessMan.getX() == chessman[i].getX()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// Move up, right
		else if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(
				1)
				&& chessManTake.getX() - chessMan.getX() == 57
				&& chessMan.getY() - chessManTake.getY() == 114) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessMan.getY() - chessman[i].getY() == 57
						&& chessMan.getX() == chessman[i].getX()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// Move down, left
		else if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(
				1)
				&& chessMan.getX() - chessManTake.getX() == 57
				&& chessManTake.getY() - chessMan.getY() == 114) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].getY() - chessMan.getY() == 57
						&& chessMan.getX() == chessman[i].getX()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// Move down, right
		else if (chessMan.getName().charAt(1) != chessManTake.getName().charAt(
				1)
				&& chessManTake.getX() - chessMan.getX() == 57
				&& chessManTake.getY() - chessMan.getY() == 114) {
			// Are there any other pieces in front
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].getY() - chessMan.getY() == 57
						&& chessMan.getX() == chessman[i].getX()
						&& chessman[i].isVisible()) {
					Move = 1;
					break;
				}
			}
			Chess = true;
		}
		// There are no obstacles and you can eat chess
		if (Move == 0 && Chess) {
			ChineseChessMainFrame.list.add(String.valueOf(3));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getName()
					.substring(2)));
			ChineseChessMainFrame.list.add(String.valueOf(2));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake
					.getName().substring(2)));
			chessManTake.setVisible(false);
			chessMan.setBounds(chessManTake.getX(), chessManTake.getY(), 55, 55);
		}
	}// The horse eats chess

	/** Phase shift rule */
	public void elephantRule(int Man, JLabel chessMan, JLabel[] chessman,
			MouseEvent me) {
		// Coordinates and obstacles
		int boardX = Math.round((float) (me.getX() - 24) / 57) * 57 + 24;
		int boardY = Math.round((float) (me.getY() - 56) / 57) * 57 + 56;
		int Move = 0;
		if (boardY >= 56 && boardY <= 569 && boardX >= 24 && boardX <= 480) {
			// Upper left
			if (chessMan.getX() - boardX == 114
					&& chessMan.getY() - boardY == 114) {
				// Is there a chess piece in the upper left
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].isVisible()
							&& chessMan.getX() - chessman[i].getX() == 57
							&& chessMan.getY() - chessman[i].getY() == 57) {
						Move++;
						break;
					}
				}
				// The red flag cannot cross the Chu River
				if (Move == 0 && Man > 9 && boardY > 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// The black flag cannot cross the Han border
				else if (Move == 0 && Man <= 9 && boardY <= 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Upper right
			else if (boardX - chessMan.getX() == 114
					&& chessMan.getY() - boardY == 114) {
				// Is there a chess piece in the upper right
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].isVisible()
							&& chessman[i].getX() - chessMan.getX() == 57
							&& chessMan.getY() - chessman[i].getY() == 57) {
						Move++;
						break;
					}
				}
				// The red flag cannot cross the Chu River
				if (Move == 0 && Man > 9 && boardY > 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// The black flag cannot cross the Han border
				else if (Move == 0 && Man <= 9 && boardY <= 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Lower left
			else if (chessMan.getX() - boardX == 114
					&& boardY - chessMan.getY() == 114) {
				// Is there a chess piece at the bottom left
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].isVisible()
							&& chessMan.getX() - chessman[i].getX() == 57
							&& chessman[i].getY() - chessMan.getY() == 57) {
						Move++;
						break;
					}
				}
				// The red flag cannot cross the Chu River
				if (Move == 0 && Man > 9 && boardY > 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// The black flag cannot cross the Han border
				else if (Move == 0 && Man <= 9 && boardY <= 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Lower right
			else if (boardX - chessMan.getX() == 114
					&& boardY - chessMan.getY() == 114) {
				// Is there a chess piece at the bottom right
				for (int i = 0; i < chessman.length; i++) {
					if (chessman[i].isVisible()
							&& chessman[i].getX() - chessMan.getX() == 57
							&& chessman[i].getY() - chessMan.getY() == 57) {
						Move++;
						break;
					}
				}
				// The red flag cannot cross the Chu River
				if (Move == 0 && Man > 9 && boardY > 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// The black flag cannot cross the Han border
				else if (Move == 0 && Man <= 9 && boardY <= 284) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
		}
	}// End of phase shift rule

	/** Rules of Xiang Xiang eating chess */
	public void elephantRule(JLabel chessMan, JLabel chessManTake,
			JLabel[] chessman) {
		// obstacle
		int Move = 0;
		boolean Chess = false;
		// Upper left
		if (chessMan.getX() - chessManTake.getX() == 114
				&& chessMan.getY() - chessManTake.getY() == 114) {
			// Is there a chess piece in the upper left
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].isVisible()
						&& chessMan.getX() - chessman[i].getX() == 57
						&& chessMan.getY() - chessman[i].getY() == 57) {
					Move++;
					break;
				}
			}
			Chess = true;
		}
		// Upper right
		else if (chessManTake.getX() - chessMan.getX() == 114
				&& chessMan.getY() - chessManTake.getY() == 114) {
			// Is there a chess piece in the upper right
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].isVisible()
						&& chessman[i].getX() - chessMan.getX() == 57
						&& chessMan.getY() - chessman[i].getY() == 57) {
					Move++;
					break;
				}
			}
			Chess = true;
		}
		// Lower left
		else if (chessMan.getX() - chessManTake.getX() == 114
				&& chessManTake.getY() - chessMan.getY() == 114) {
			// Is there a chess piece at the bottom left
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].isVisible()
						&& chessMan.getX() - chessman[i].getX() == 57
						&& chessman[i].getY() - chessMan.getY() == 57) {
					Move++;
					break;
				}
			}
			Chess = true;
		}
		// Lower right
		else if (chessManTake.getX() - chessMan.getX() == 114
				&& chessManTake.getY() - chessMan.getY() == 114) {
			// Is there a chess piece at the bottom right
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].isVisible()
						&& chessman[i].getX() - chessMan.getX() == 57
						&& chessman[i].getY() - chessMan.getY() == 57) {
					Move++;
					break;
				}
			}
			Chess = true;
		}
		// There are no obstacles and you can't eat your own chess pieces
		if (Chess
				&& Move == 0
				&& chessMan.getName().charAt(1) != chessManTake.getName()
						.charAt(1)) {
			ChineseChessMainFrame.list.add(String.valueOf(3));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getName()
					.substring(2)));
			ChineseChessMainFrame.list.add(String.valueOf(2));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake
					.getName().substring(2)));
			chessManTake.setVisible(false);
			chessMan.setBounds(chessManTake.getX(), chessManTake.getY(), 55, 55);
		}
	}// The rules of Xiangxiang eating chess are over

	/** Moving method of Shi and Shi */
	public void chapRule(int Man, JLabel chessMan, JLabel[] chessman,
			MouseEvent me) {
		// coordinate
		int boardX = Math.round((float) (me.getX() - 24) / 57) * 57 + 24;
		int boardY = Math.round((float) (me.getY() - 56) / 57) * 57 + 56;
		if (boardY >= 56 && boardY <= 569 && boardX >= 24 && boardX <= 480) {
			// Upper left
			if (chessMan.getX() - boardX == 57
					&& chessMan.getY() - boardY == 57) {
				// You can't go beyond your own boundaries
				if (Man < 14 && boardX >= 195 && boardX <= 252 && boardY >= 56
						&& boardY <= 113) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// You can't go beyond your own boundaries
				else if (Man > 13 && boardX >= 195 && boardX <= 252
						&& boardY >= 455 && boardY <= 512) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Upper right
			else if (boardX - chessMan.getX() == 57
					&& chessMan.getY() - boardY == 57) {
				// A scholar cannot exceed his own boundaries
				if (Man < 14 && boardX >= 252 && boardX <= 309 && boardY >= 56
						&& boardY <= 113) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// You can't go beyond your own boundaries
				else if (Man > 13 && boardX >= 252 && boardX <= 309
						&& boardY >= 455 && boardY <= 512) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Lower left
			else if (chessMan.getX() - boardX == 57
					&& boardY - chessMan.getY() == 57) {
				// You can't go beyond your own boundaries
				if (Man < 14 && boardX >= 195 && boardX <= 252 && boardY >= 113
						&& boardY <= 170) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// You can't go beyond your own boundaries
				else if (Man > 13 && boardX >= 195 && boardX <= 252
						&& boardY >= 512 && boardY <= 569) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Lower right
			else if (boardX - chessMan.getX() == 57
					&& boardY - chessMan.getY() == 57) {
				// You can't go beyond your own boundaries
				if (Man < 14 && boardX >= 252 && boardX <= 309 && boardY >= 113
						&& boardY <= 170) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// You can't go beyond your own boundaries
				else if (Man > 13 && boardX >= 252 && boardX <= 309
						&& boardY >= 512 && boardY <= 569) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
		}
	}// End of move rule

	/** Rules of chess */
	public void chapRule(int Man, JLabel chessMan, JLabel chessManTake,
			JLabel[] chessman) {
		// current state
		boolean Chap = false;
		// Upper left
		if (chessMan.getX() - chessManTake.getX() == 57
				&& chessMan.getY() - chessManTake.getY() == 57) {
			// You can't go beyond your own boundaries
			if (Man < 14 && chessManTake.getX() >= 195
					&& chessManTake.getX() <= 252 && chessManTake.getY() >= 56
					&& chessManTake.getY() <= 113 && chessManTake.isVisible()) {
				Chap = true;
			}
			// You can't go beyond your own boundaries
			else if (Man > 13 && chessManTake.getX() >= 195
					&& chessManTake.getX() <= 252 && chessManTake.getY() >= 455
					&& chessManTake.getY() <= 512 && chessManTake.isVisible()) {
				Chap = true;
			}
		}
		// Upper right
		else if (chessManTake.getX() - chessMan.getX() == 57
				&& chessMan.getY() - chessManTake.getY() == 57) {
			// You can't go beyond your own boundaries
			if (Man < 14 && chessManTake.getX() >= 252
					&& chessManTake.getX() <= 309 && chessManTake.getY() >= 56
					&& chessManTake.getY() <= 113 && chessManTake.isVisible()) {
				Chap = true;
			}
			// You can't go beyond your own boundaries
			else if (Man > 13 && chessManTake.getX() >= 252
					&& chessManTake.getX() <= 309 && chessManTake.getY() >= 455
					&& chessManTake.getY() <= 512 && chessManTake.isVisible()) {
				Chap = true;
			}
		}
		// Lower left
		else if (chessMan.getX() - chessManTake.getX() == 57
				&& chessManTake.getY() - chessMan.getY() == 57) {
			// You can't go beyond your own boundaries
			if (Man < 14 && chessManTake.getX() >= 195
					&& chessManTake.getX() <= 252 && chessManTake.getY() >= 113
					&& chessManTake.getY() <= 170 && chessManTake.isVisible()) {
				Chap = true;
			}
			// You can't go beyond your own boundaries
			else if (Man > 13 && chessManTake.getX() >= 195
					&& chessManTake.getX() <= 252 && chessManTake.getY() >= 512
					&& chessManTake.getY() <= 569 && chessManTake.isVisible()) {
				Chap = true;
			}
		}
		// Lower right
		else if (chessManTake.getX() - chessMan.getX() == 57
				&& chessManTake.getY() - chessMan.getY() == 57) {
			// You can't go beyond your own boundaries
			if (Man < 14 && chessManTake.getX() >= 252
					&& chessManTake.getX() <= 309 && chessManTake.getY() >= 113
					&& chessManTake.getY() <= 170 && chessManTake.isVisible()) {
				Chap = true;
			}
			// You can't go beyond your own boundaries
			else if (Man > 13 && chessManTake.getX() >= 252
					&& chessManTake.getX() <= 309 && chessManTake.getY() >= 512
					&& chessManTake.getY() <= 569 && chessManTake.isVisible()) {
				Chap = true;
			}
		}
		// Movable and unable to eat their own pieces
		if (Chap
				&& chessMan.getName().charAt(1) != chessManTake.getName()
						.charAt(1)) {
			ChineseChessMainFrame.list.add(String.valueOf(3));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getName()
					.substring(2)));
			ChineseChessMainFrame.list.add(String.valueOf(2));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake
					.getName().substring(2)));
			chessManTake.setVisible(false);
			chessMan.setBounds(chessManTake.getX(), chessManTake.getY(), 55, 55);
		}
	}// The rules of Shi and Shi eating chess are over

	/** Move rule */
	public void willRule(int Man, JLabel chessMan, JLabel[] chessman,
			MouseEvent me) {
		// coordinate
		int boardX = Math.round((float) (me.getX() - 24) / 57) * 57 + 24;
		int boardY = Math.round((float) (me.getY() - 56) / 57) * 57 + 56;
		if (boardY >= 56 && boardY <= 569 && boardX >= 24 && boardX <= 480) {
			// upper
			if (chessMan.getX() == boardX && chessMan.getY() - boardY == 57) {
				// Will not be able to exceed their own boundaries
				if (Man == 30 && boardY >= 56 && boardY <= 113) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// Handsome can not exceed their own boundaries
				else if (Man == 31 && boardY >= 455 && boardY <= 512) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// lower
			else if (chessMan.getX() == boardX
					&& boardY - chessMan.getY() == 57) {
				// Will not be able to exceed their own boundaries
				if (Man == 30 && boardY >= 113 && boardY <= 170) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// Handsome can not exceed their own boundaries
				else if (Man == 31 && boardY >= 512 && boardY <= 569) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// Left
			else if (chessMan.getY() == boardY
					&& chessMan.getX() - boardX == 57) {
				// Will not be able to exceed their own boundaries
				if (Man == 30 && boardX >= 195 && boardX <= 252) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// Handsome can not exceed their own boundaries
				else if (Man == 31 && boardX >= 195 && boardX <= 252) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
			// right
			else if (chessMan.getY() == boardY
					&& boardX - chessMan.getX() == 57) {
				// Will not be able to exceed their own boundaries
				if (Man == 30 && boardX >= 252 && boardX <= 309) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
				// Handsome can not exceed their own boundaries
				else if (Man == 31 && boardX >= 252 && boardX <= 309) {
					ChineseChessMainFrame.list.add(String.valueOf(1));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getX()));
					ChineseChessMainFrame.list.add(String.valueOf(chessMan
							.getY()));
					ChineseChessMainFrame.list.add(String.valueOf(Man));
					chessMan.setBounds(boardX, boardY, 55, 55);
				}
			}
		}
	}// End the move rule

	/** Will eat chess rules */
	public void willRule(int Man, JLabel chessMan, JLabel chessManTake,
			JLabel[] chessman) {
		// current state
		boolean will = false;
		int count = 0;

		if (chessMan.getX() == chessManTake.getX()
				&& chessMan.getName().charAt(0) == 'take'
				&& chessManTake.getName().charAt(0) == 'take') {
			for (int i = 0; i < chessman.length; i++) {
				if (chessman[i].getX() == chessMan.getX()
						&& !chessman[i].getName().equals(chessMan.getName())
						&& !chessman[i].getName()
								.equals(chessManTake.getName())
						&& chessman[i].isVisible()) {
					count++;
				}
			}
			if (count == 0) {
				will = true;
			}
		}
		// upper
		else if (chessMan.getX() == chessManTake.getX()
				&& chessMan.getY() - chessManTake.getY() == 57) {

			// Will not be able to exceed their own boundaries
			if (Man == 30 && chessManTake.getY() >= 56
					&& chessManTake.getY() <= 113) {
				will = true;
			}
			// Handsome can not exceed their own boundaries
			else if (Man == 31 && chessManTake.getY() >= 455
					&& chessManTake.getY() <= 512) {
				will = true;
			}
		}
		// lower
		else if (chessMan.getX() == chessManTake.getX()
				&& chessManTake.getY() - chessMan.getY() == 57) {
			// Will not be able to exceed their own boundaries
			if (Man == 30 && chessManTake.getY() >= 113
					&& chessManTake.getY() <= 170) {
				will = true;
			}
			// Handsome can not exceed their own boundaries
			else if (Man == 31 && chessManTake.getY() >= 512
					&& chessManTake.getY() <= 569) {
				will = true;
			}
		}
		// Left
		else if (chessMan.getY() == chessManTake.getY()
				&& chessMan.getX() - chessManTake.getX() == 57) {
			// Will not be able to exceed their own boundaries
			if (Man == 30 && chessManTake.getX() >= 195
					&& chessManTake.getX() <= 252) {
				will = true;
			}
			// Handsome can not exceed their own boundaries
			else if (Man == 31 && chessManTake.getX() >= 195
					&& chessManTake.getX() <= 252) {
				will = true;
			}
		}
		// right
		else if (chessMan.getY() == chessManTake.getY()
				&& chessManTake.getX() - chessMan.getX() == 57) {
			// Will not be able to exceed their own boundaries
			if (Man == 30 && chessManTake.getX() >= 252
					&& chessManTake.getX() <= 309) {
				will = true;
			}
			// Handsome can not exceed their own boundaries
			else if (Man == 31 && chessManTake.getX() >= 252
					&& chessManTake.getX() <= 309) {
				will = true;
			}
		}
		if (will
				&& chessMan.getName().charAt(1) != chessManTake.getName()
						.charAt(1)) {
			ChineseChessMainFrame.list.add(String.valueOf(3));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessMan.getName()
					.substring(2)));
			ChineseChessMainFrame.list.add(String.valueOf(2));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getX()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake.getY()));
			ChineseChessMainFrame.list.add(String.valueOf(chessManTake
					.getName().substring(2)));
			chessManTake.setVisible(false);
			chessMan.setBounds(chessManTake.getX(), chessManTake.getY(), 55, 55);
		}
	}// End the rules of eating and handsome chess

}

4, Other

1. More systems

Java swing system series implementation

Realizing landlords fighting game with Java+Swing

Implementation of library management system with Java+Swing

Implementation of hospital management system with Java+Swing

Implementation of examination management system with Java+Swing

Implementation of hotel management system with Java+Swing

Implementation of supermarket management system with Java+Swing

Implementation of movie ticket purchase system with Java+Swing

Implementation of warehouse management System-1 with Java+Swing

Java+Swing to realize warehouse management System-2

Implementation of purchase, sales and inventory management system with Java+Swing

Implementation of self-service ATM system with Java+Swing

Implementation of address book management system with Java+Swing

Implementation of parking lot management system with Java+Swing

Implementation of Java+Swing student information management system

Implementation of student dormitory management system with Java+Swing

Implementation of student course selection management system with Java+Swing

Implementation of student achievement management system with Java+Swing

Implementation of school textbook management system with Java+Swing

Implementation of school educational administration management system with Java+Swing

Implementation of enterprise personnel management system with Java+Swing

Implementation of electronic album management system with Java+Swing

Java+Swing to realize supermarket management system TXT to store data

Java+Swing to realize self-service ATM system - TXT to store data

Java+Swing to realize pet store management system TXT to store data

Java+JSP system series implementation

Implementation of student library management system with Java+JSP

Implementation of student information management system with Java+JSP

Implementation of user information management system with Java+JSP

Java+Servlet system series implementation

Implementation of air booking system with Java+Servlet+JSP

Realization of news release system with Java+Servlet+JSP

Java+Servlet+JSP student dormitory management system

Implementation of library management system with Java+Servlet+JSP

Realization of parking lot management system with Java+Servlet+JSP

Realization of house rental management system with Java+Servlet+JSP

Implementation of student information management system with Java+Servlet+JSP

Implementation of student course selection management system with Java+Servlet+JSP

Implementation of pet clinic management system with Java+Servlet+JSP

Implementation of student achievement management System-1 with Java+Servlet+JSP

Java+Servlet+JSP to realize student achievement management System-2

Java+SSM system series implementation

Implementation of library management system with Java+SSM+JSP

Realizing supermarket order system with Java+SSM+JSP

J # ava+SSM+JSP to realize online examination system

Implementation of pet mall system with Java+SSM+JSP

Implementation of student achievement management system with Java+SSM+Layui

Implementation of student information management system with Java+SSM+Bootstrap

Java+SSH system series implementation

Implementation of online examination system with Java+SSH+JSP

Implementation of hospital online registration system with Java+SSH+JSP

Java+Springboot system series implementation

Implementation of marketing management system with Java+Springboot+H-ui+Maven

Java+Springboot+Bootstrap+Maven to realize the online mall system

Implement scenic spot tourism management system with Java+Springboot+Bootstrap+Maven

1. For more java web systems, please pay attention to the column.

https://blog.csdn.net/helongqiang/category_10020130.htmlhttps://blog.csdn.net/helongqiang/category_10020130.html

2. For more JavaSwing systems, please pay attention to the column.

https://blog.csdn.net/helongqiang/category_6229101.htmlhttps://blog.csdn.net/helongqiang/category_6229101.html

2. Source code download

Chinese chess game realized by Java+Swing

3. Operation project

Please click the link below to deploy your project.

Eclipse how to import Java Swing project hyperdetailed graphic tutorial

Eclipse how to import Java Swing project super detailed video tutorial

4. Remarks

If there is infringement, please contact me to delete.

5. Blogger support

If you think this article is helpful to you, please pay attention to it. I wish you a happy life!

Topics: Java Game Development