package 游戏界面;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.DataOutputStream;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import 客户端与服务端.*;
public class GameHall_GUI extends JFrame implements ActionListener
{
Client client = null;
private boolean isCreatNewTab;
//选项卡
JTabbedPane gameHall_tab = new JTabbedPane(); //游戏大厅
JTabbedPane userInfo_tab = new JTabbedPane(); //个人信息
JTabbedPane severInfo_tab = new JTabbedPane(); //服务器信息
//分隔面板
JSplitPane gameHall_split = new JSplitPane(); //水平分隔的游戏大厅面板
JSplitPane Info_split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); //垂直分割的信息面板
//每个选项卡的容器
JPanel userInfo_panel = new JPanel(); //用户信息容器
JPanel severInfo_panel = new JPanel(); //服务器信息容器
JPanel match_panel = new JPanel(); //匹配面板容器
JTextArea dialog_area = new JTextArea();
JTextField message_field = new JTextField();
String userName = null;
ImageIcon userImage = null;
ImageIcon null_image = new ImageIcon("./src/图片/资源包/res/img/noone.gif");
ImageIcon desk_image = new ImageIcon("./src/图片/资源包/res/img/xqnoone.gif");
JLabel userName_lab;
JLabel userPhoto_lab = new JLabel(new ImageIcon("./src/图片/资源包/res/img/boy1.gif"), JLabel.CENTER);
JLabel tag1_lab = new JLabel(">>>>匹配大厅<<<<");
JLabel desk_lab = new JLabel();
JLabel orderNum_lab;
JLabel IP_lab = new JLabel("服务器:127.0.0.1");
JLabel onlineUser_lab = new JLabel();
JLabel[] leftName_lab = new JLabel[15];
JLabel[] rightName_lab = new JLabel[15];
JLabel myState_lab = new JLabel("未准备");
JLabel oppoState_lab = new JLabel();
JButton match_btn = new JButton("自动匹配");
JButton exit1_btn = new JButton("退出");
JButton[] leftImage_btn = new JButton[15];
JButton[] rightImage_btn = new JButton[15];
JButton send_btn = new JButton("发送");
JButton exit2_btn = new JButton("退出");
JButton start_btn = new JButton("开始");
JButton request_btn = new JButton("求和");
JButton admitDefeat_btn = new JButton("认输");
public GameHall_GUI(String userName, String imagePath, Client client)
{
isCreatNewTab = false;
this.client = client;
this.userName = userName;
userImage = new ImageIcon(imagePath);
userName_lab = new JLabel("用户名:" + this.userName, JLabel.CENTER);
this.client.setDesk(leftName_lab, rightName_lab, leftImage_btn, rightImage_btn, onlineUser_lab);
}
public void EnterGameRoom()
{
JTabbedPane myInfo_tab = new JTabbedPane(); //我的信息
JTabbedPane opponentInfo_tab = new JTabbedPane(); //对手信息
JTabbedPane chat_tab = new JTabbedPane(); //聊天窗口
JSplitPane gamerRoom_split = new JSplitPane(); //游戏房间面板
JSplitPane playerInfo_split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); //玩家信息面板
JSplitPane playerInfo_split1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT); //玩家信息面板
JPanel chess_panel = new JPanel(); //棋盘面板容器
JPanel myInfo_panel = new JPanel(); //我的信息容器
JPanel opponentInfo_panel = new JPanel(); //对手信息容器
JPanel chat_panel = new JPanel(); //聊天面板容器
JPanel chatSouth = new JPanel(); //聊天面板南部容器
JPanel north = new JPanel();
JPanel center = new JPanel();
JPanel south = new JPanel();
JPanel my_north = new JPanel();
JPanel my_center = new JPanel();
JPanel oppo_north = new JPanel();
JPanel oppo_center = new JPanel();
JLabel tag2_lab = new JLabel(">>>>五子棋游戏房间<<<<");
JLabel myName_lab = new JLabel();
JLabel myImage_lab = new JLabel();
JLabel opponentName_lab = new JLabel(" ");
JLabel opponentImage_lab = new JLabel(null_image);
ChessBoard cb = new ChessBoard(client, userName);
// client.sendMSG("enter:");
client.setMsgAera(dialog_area);
client.setButton(request_btn, admitDefeat_btn, start_btn);
client.setGameRoom(cb, gameHall_tab, myName_lab, myImage_lab, opponentName_lab, opponentImage_lab, myState_lab, oppoState_lab);
client.enterGameRoom();
gameHall_tab.addTab("游戏房间", gamerRoom_split);
opponentInfo_tab.add("对手", opponentInfo_panel);
myInfo_tab.add("自己", myInfo_panel);
chat_tab.add("聊天", chat_panel);
// 游戏房间
gamerRoom_split.setDividerSize(3);
gamerRoom_split.setDividerLocation(270);
gamerRoom_split.setContinuousLayout(true);
gamerRoom_split.setLeftComponent(playerInfo_split);
gamerRoom_split.setRightComponent(chess_panel);
playerInfo_split.setBackground(Color.WHITE);
playerInfo_split.setDividerSize(3);
playerInfo_split.setDividerLocation(490);
playerInfo_split.setContinuousLayout(true);
playerInfo_split.setTopComponent(playerInfo_split1);
playerInfo_split.setBottomComponent(chat_tab);
playerInfo_split1.setBackground(Color.WHITE);
playerInfo_split1.setDividerSize(3);
playerInfo_split1.setDividerLocation(240);
playerInfo_split1.setContinuousLayout(true);
playerInfo_split1.setTopComponent(opponentInfo_tab);
playerInfo_split1.setBottomComponent(myInfo_tab);
//我的信息和对手信息
myState_lab.setForeground(Color.BLUE);
myState_lab.setFont(new Font("微软雅黑", Font.LAYOUT_LEFT_TO_RIGHT, 16));
oppoState_lab.setForeground(Color.BLUE);
oppoState_lab.setFont(new Font("微软雅黑", Font.LAYOUT_LEFT_TO_RIGHT, 16));
myName_lab.setFont(new Font("微软雅黑", Font.LAYOUT_LEFT_TO_RIGHT, 16));
opponentName_lab.setFont(new Font("微软雅黑", Font.LAYOUT_LEFT_TO_RIGHT, 16));
my_north.setLayout(new GridLayout(1, 3, 0, 0));
my_north.setBackground(Color.WHITE);
my_north.add(Box.createHorizontalStrut(0));
my_north.add(myImage_lab);
my_north.add(myName_lab);
my_center.add(myState_lab);
my_center.setBackground(Color.WHITE);
myInfo_panel.setLayout(new BorderLayout());
myInfo_panel.add(my_north, "North");
myInfo_panel.add(my_center, "South");
myInfo_panel.setBackground(Color.WHITE);
oppo_north.setLayout(new GridLayout(1, 3, 0, 0));
oppo_north.setBackground(Color.WHITE);
oppo_north.add(Box.createHorizontalStrut(0));
oppo_north.add(opponentImage_lab);
oppo_north.add(opponentName_lab);
oppo_center.add(oppoState_lab);
oppo_center.setBackground(Color.WHITE);
opponentInfo_panel.setLayout(new BorderLayout());
opponentInfo_panel.add(oppo_north, "North");
opponentInfo_panel.add(oppo_center, "South");
opponentInfo_panel.setBackground(Color.WHITE);
//聊天区域
chatSouth.setLayout(new BorderLayout());
chatSouth.add(message_field,"Center");
chatSouth.add(send_btn,"East");
chat_panel.setLayout(new BorderLayout());
chat_panel.add(new JScrollPane(dialog_area),"Center");
chat_panel.add(chatSouth,"South");
// chat_panel.setLayout(new GridBagLayout());
// GridBagConstraints chat_gb = new GridBagConstraints();
// chat_gb.fill = GridBagConstraints.BOTH;
//
// chat_gb.gridy = 0; //对话区域放在第0行
// chat_gb.gridx = 0; //对话区域放在第0列
// chat_gb.weighty = 1; //对话区域垂直可拉伸
// chat_gb.weightx = 1; //对话区域水平可拉伸
// chat_gb.gridheight = 2; //对话区域占用2行
// chat_gb.gridwidth = 2; //对话区域占用2列
// chat_panel.add(new JScrollPane(dialog_area), chat_gb);
//
// chat_gb.gridy = 2;
// chat_gb.gridx =
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源内项目代码都是经过测试运行成功,功能正常的情况下才上传的,请放心下载使用。 2、适用人群:主要针对计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、数学、电子信息等)的同学或企业员工下载使用,具有较高的学习借鉴价值。 3、不仅适合小白学习实战练习,也可作为大作业、课程设计、毕设项目、初期项目立项演示等,欢迎下载,互相学习,共同进步! 联网五子棋游戏源码(实现多个客户在局域网对战聊天功能+分为游戏服务端和游戏客户端。游戏服务端主要存储所有连线客户的相关信息及各种状态,并负责游戏客户之间数据的传递,具有连接服务器、挑战、传送聊天信息等等功能;游戏客户端提 供客户连接服务器).zip
资源推荐
资源详情
资源评论
收起资源包目录
联网五子棋游戏完整源码(实现多个客户在局域网对战聊天功能+分为游戏服务端和游戏客户端).zip (582个子文件)
GameHall_GUI.class 13KB
ReadMsgThread.class 9KB
Client.class 8KB
ChessBoard.class 5KB
Login_GUI.class 5KB
Server.class 3KB
Client$oppoTimeThread.class 2KB
Client$myTimeThread.class 2KB
User.class 2KB
ChessMatrix.class 2KB
Table.class 1KB
Chess.class 391B
.classpath 404B
board.gif 60KB
board.gif 60KB
board1.gif 59KB
board1.gif 59KB
boy1.gif 25KB
boy1.gif 25KB
start.gif 4KB
start.gif 4KB
xiangqi.gif 4KB
r5.gif 4KB
xiangqi.gif 4KB
r5.gif 4KB
xqnoone.gif 3KB
xqnoone.gif 3KB
wuziqi.gif 2KB
wuziqi.gif 2KB
noone.gif 1KB
noone.gif 1KB
57-2.gif 617B
57-2.gif 617B
83-2.gif 591B
83-2.gif 591B
81-2.gif 577B
81-2.gif 577B
57-1.gif 564B
57-1.gif 564B
29-2.gif 563B
29-2.gif 563B
57-3.gif 562B
57-3.gif 562B
45-2.gif 539B
45-2.gif 539B
81-1.gif 505B
81-1.gif 505B
29-3.gif 487B
29-3.gif 487B
29-1.gif 486B
29-1.gif 486B
83-3.gif 481B
83-3.gif 481B
84-2.gif 478B
84-2.gif 478B
83-1.gif 477B
83-1.gif 477B
81-3.gif 476B
81-3.gif 476B
59-2.gif 468B
59-2.gif 468B
45-1.gif 467B
45-1.gif 467B
75-2.gif 461B
75-2.gif 461B
79-2.gif 458B
79-2.gif 458B
77-2.gif 452B
77-2.gif 452B
75-1.gif 451B
75-1.gif 451B
72-2.gif 450B
72-2.gif 450B
75-3.gif 446B
75-3.gif 446B
36-2.gif 445B
36-2.gif 445B
37-1.gif 438B
37-1.gif 438B
4-3.gif 435B
4-3.gif 435B
4-2.gif 432B
4-1.gif 432B
4-2.gif 432B
4-1.gif 432B
68-2.gif 429B
68-2.gif 429B
77-1.gif 428B
77-1.gif 428B
20-1.gif 426B
20-1.gif 426B
55-2.gif 425B
55-2.gif 425B
58-1.gif 422B
58-2.gif 422B
58-1.gif 422B
58-2.gif 422B
60-1.gif 420B
37-3.gif 420B
60-1.gif 420B
共 582 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
龙年行大运
- 粉丝: 1006
- 资源: 3850
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Idea Note.apk
- 通过navicat操作数据库.flv
- frameworks 之线程类使用 原生和自定义的线程类
- 华为OD机试C卷- 园区参观路径(Java & JS & Python & C).md-私信看全套OD代码及解析
- 华为OD机试C卷- 寻找最优的路测线路(Java & JS & Python & C).md-私信看全套OD代码及解析
- 华为OD机试C卷- 田忌赛马(Java & JS & Python & C).md-私信看全套OD代码及解析
- 华为OD机试C卷- 特殊的加密算法(Java & JS & Python & C).md-私信看全套OD代码及解析
- 华为OD机试C卷- 贪吃蛇(Java & JS & Python).md-私信看全套OD代码及解析
- 电子迎宾器和声光控照明开关multsim仿真和课设报告
- 深度学习 KAN 最新发布论文
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功