java象棋注册界面代码_分享网上找到的一个中国象棋源码

package com.yaoyun.chess.main;

import java.awt.Cursor;

import java.io.File;

import java.io.IOException;

import javax.imageio.ImageIO;

import javax.swing.JFrame;

import javax.swing.UIManager;

import com.yaoyun.chess.controller.Controller;

import com.yaoyun.chess.entity.ChessBoard;

import com.yaoyun.chess.entity.ChessMan;

import com.yaoyun.chess.menu.ChessMenu;

import com.yaoyun.chess.panel.GamePanel;

@SuppressWarnings("serial")

public class ChineseChess extends JFrame {

public ChineseChess() throws IOException {

// 创建游戏中的对象

ChessBoard chessBoard = new ChessBoard();

ChessMan chessMan = new ChessMan();

GamePanel gamePanel = new GamePanel();

Controller controller = new Controller(gamePanel, chessBoard, chessMan);

// 添加游戏面板

this.add(gamePanel);

// 设置菜单栏

this.setJMenuBar(new ChessMenu().getChessMenu());

// 把进入窗口的鼠标设置为手型

this.setCursor(new Cursor(Cursor.HAND_CURSOR));

// 设置标题

this.setTitle("中国象棋");

// 添加鼠标监听

this.addMouseListener(controller);

// 设置窗口的图标

this.setIconImage(ImageIO.read(new File("src/res/chess.jpg")));

// 设置窗口大小

this.setSize(605, 710);

// 设置窗口默认关闭方式

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// 设置窗口大小不可改变

this.setResizable(false);

// 设置窗口居中

this.setLocationRelativeTo(null);

// 设置窗口显示

this.setVisible(true);

}

/*

* 功能:Main函数

*/

public static void main(String[] args) {

try {

// 把游戏界面设置为本地界面风格

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

// 创建游戏

new ChineseChess();

} catch (Exception e) {

System.exit(0);

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值