个人负责模块

本文档介绍了作者在实践中搭建游戏模块的过程,包括窗口搭建、游戏规则按钮功能的实现和输入聊天功能的添加。在遇到鼠标监听器问题时,作者通过查阅资料和参考代码成功解决,提升了自身能力,并认识到团队合作的重要性。强调了理论结合实践对于深入理解技术的关键作用。
摘要由CSDN通过智能技术生成

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


架构图

个人功能模块

部分代码

1、窗口的搭建

public class ClientWindow extends JFrame{
   
	public static ClientChessBoard qipan;
	ClientChat talk = new ClientChat();;
	public ClientWindow(){
   
		qipan = new ClientChessBoard(); 
		this.setSize(1150, 550);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//EXIT_ON_CLOSE(在JFrame中定义:使用System exit方法退出应用程序,仅在应用程序中使用)
		this.setTitle("五子棋客户端");
		this.add(qipan,BorderLayout.CENTER); 
		this.add(talk,BorderLayout.WEST);
		this.setVisible(true);
		}
}

2、游戏规则按钮功能的添加

public class ClientChessBoard extends JPanel {
   

	Image board, black, white;
	int getx = 0, gety = 0;// 获取客户端棋盘坐标
	static boolean xiaqi = true; 
	int cou = 0;//连珠数
	String message = ""; // 发送的消息
	Send_message sendmessage; // 发送的方法
	int hgex = 0, hgey = 0;
	public static String control; // 按钮控制
	public static boolean isgamestart = false;
	public static boolean myselfok = false; // 为true表示自己准备好了
	public static boolean duifangok = false; // 为true表示对方准备好了
	public static boolean ismyselfxiaqi = true; // 轮到自己下了
	public static boolean isduifangxiaqi = false; // 轮到对方下了
	private MouseEvent xiaqie; // 下白棋的时候,白棋点的鼠标位置的全局变量
	 
	public static ArrayList<String> myself_list = new ArrayList<String>();// 自己下棋的数集
	public static ArrayList<String> duifang_list = new ArrayList<String>(); // 对方下棋的数集

	public ClientChessBoard() {
   
		sendmessage = new Send_message(message, ClientChat.socket);// 创建一个对象,并且实例化
		this.setLayout(null);
		JButton ks = new J
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值