wzq.zip

  • 栗子chestnut24
    了解作者
  • Java
    开发工具
  • 58KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2020-06-08 09:27
    上传日期
使用java开发的简单的五子棋对战系统,拥有可视化界面
wzq.zip
  • wzq
  • Source
  • Server.java
    1.3KB
  • ServeOneClient.java
    17.9KB
  • Player.java
    340B
  • BoardPanel.java
    23.4KB
  • ChessWZQ.java
    27.9KB
  • Group.java
    472B
  • Message.java
    1.3KB
  • Class
  • ChessWZQ.class
    13.4KB
  • BoardPanel$Queue.class
    380B
  • client1.bat
    27B
  • compile.bat
    141B
  • ChessWZQ$1.class
    1.1KB
  • ChessWZQ.java~1~
    31.1KB
  • Player.class
    384B
  • ChessWZQ$3.class
    632B
  • BoardPanel$Analyse.class
    4.8KB
  • client2.bat
    27B
  • Group.class
    556B
  • ChessWZQ.java~2~
    30.9KB
  • ChessWZQ$7.class
    1.7KB
  • ChessWZQ$5.class
    1.2KB
  • server.bat
    11B
  • BoardPanel.class
    6.4KB
  • Server.class
    1.2KB
  • ChessWZQ$2.class
    1.1KB
  • ChessWZQ$6.class
    690B
  • ChessWZQ$4.class
    707B
  • ChessWZQ$8.class
    1.5KB
  • ChessWZQ_this_mouseAdapter.class
    440B
  • ChessWZQ_this_mouseMotionAdapter.class
    448B
  • Message.class
    407B
  • ServeOneClient.class
    7.4KB
内容介绍
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.net.*; import java.io.*; /** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: e-top</p> * @author cylix * @version 1.0 */ public class ChessWZQ extends JFrame { JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); protected Image white = null; protected Image black = null; protected static int pColor; //用户棋子的颜色 protected static int cColor; // 计算机棋子的颜色 static boolean ptocFlag=false; boolean pFirst = false; private int bestX=0; // 计算机选择的最优落子的x坐标 private int bestY=0; // 计算机选择的最优落子的y坐标 private int RectX1=0; // 根据x和y坐标设置的矩形位置边界 private int RectY1=0; // 长度为 9 private int RectX2=0; // 大小为 9*9 private int RectY2=0; private int weightBoard[][]; static Socket socket; private static int PORT; static ObjectInputStream in; static ObjectOutputStream out; String name=null ; String serverAddress=null; static char send[]; public static Message message = new Message(); public static boolean beginFlag = false; BoardPanel bpanel = new BoardPanel(); JPanel jpanel3 = new JPanel(); JLabel label1 = new JLabel("Player1"); JLabel label2 = new JLabel(" VS "); JLabel label3 = new JLabel("Player2"); JLabel label4 = new JLabel("Player List "); JLabel label5 = new JLabel("Message list... "); static JLabel label6 = new JLabel("welcome"); JLabel label7 = new JLabel("Host"); JLabel label8 = new JLabel("Player"); JRadioButton jrbBlack = new JRadioButton("Black"); JRadioButton jrbWhite = new JRadioButton("White"); DefaultListModel lItems = new DefaultListModel(); JList list = new JList(lItems); JMenuBar mb = new JMenuBar(); JMenu create = new JMenu("Create"); JMenu setting = new JMenu("Setting"); JMenu quit = new JMenu("Quit"); JMenu about = new JMenu("About"); JMenuItem cPtoP = new JMenuItem("Play With people"); JMenuItem cPtoC = new JMenuItem("Play With Computer"); JMenuItem load = new JMenuItem("Load game..."); JMenuItem save = new JMenuItem("Save ..."); public ChessWZQ() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); getContentPane().setLayout(null); weightBoard = new int [15][15]; // 保存棋盘每一个点的权重 PORT = Server.PORT;//设置socket端口 send = new char[60]; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } try { getContentPane().setLayout(null); jrbBlack.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ bpanel.setColor(1); cColor=2; jrbBlack.setEnabled(false); jrbWhite.setEnabled(false); drawChess(1); jrbWhite.setSelected(true); if(ptocFlag==true){ return; } Message ms = new Message(); ms.color=1; ms.type=13; try{ out.writeObject(ms); }catch(IOException error){ error.printStackTrace(); } } }); jrbWhite.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ bpanel.setColor(2); cColor=1; jrbWhite.setEnabled(false); jrbBlack.setEnabled(false); drawChess(2); jrbBlack.setSelected(false); if(ptocFlag==true){ return; } Message ms = new Message(); ms.color=2; ms.type=13; try{ out.writeObject(ms); }catch(IOException error){ error.printStackTrace(); } } }); about.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ JOptionPane.showMessageDialog(null, "author: cylix \nCopyright (c) 2003 e-top\nmail:cylix_xtcc@sina.com", "五子棋1.0(beta)",JOptionPane.INFORMATION_MESSAGE); } }); quit.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ int flag=JOptionPane.showConfirmDialog(null, "Quit the Program ?", "Are you sure to quit ?", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); if(flag==0){ // 断开与服务器的连接 sendDisconnect(); System.exit(0); } } }); setting.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ Object selection[] = {"Forbiden","Allow any"}; Object set = JOptionPane.showInputDialog(null, "Setting...","would you allow any method?", JOptionPane.QUESTION_MESSAGE,null,selection,selection[0]); if(ptocFlag==true){ return; } Message ms = new Message(); if(set==null){ return; } if(set.toString().equals(selection[0])){ ms.setting=false; } else{ ms.setting=true; } ms.type=12; try{ out.writeObject(ms); }catch(IOException error){ error.printStackTrace(); } } }); cPtoP.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ ptocFlag=false; JOptionPane.showMessageDialog(null, "You can choose a player from the listBox on the right","Welcome...", JOptionPane.INFORMATION_MESSAGE); } }); cPtoC.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if(ptocFlag==true){ int flag=JOptionPane.showConfirmDialog(null, "You give up... ?","Message", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); if(flag==0){ newGame(); return; } } label3.setText("Computer"); Object selection[] = {"Computer First","You First"}; Object set = JOptionPane.showInputDialog(null, "choose who first...","setting...", JOptionPane.QUESTION_MESSAGE,null, selection,selection[0]); ptoc
评论
    相关推荐
    • Java
      Java 对于Java练习
    • java
      Java Java基础
    • Java
      Java 我创建的Java项目
    • JAVA教程
      一本非常不错的清华大学java教程,讲解非常详细,看了就知道。
    • Java Cipher
      Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码
    • javabank
      Java银行 Java com的模拟操作将在bancárias上发布! 要求:Java 8。
    • java 李兴华
      java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java ...
    • Java204
      支持中文,支持动态注释的超强Java语言反编译器。 注意:Java204的工作目录中不能包含中文字符!! 支持现有所有Java环境产生的Class代码,而最重要的是它生成的源代码可读性极好,又充分考虑了国人的Java编码习惯,...
    • java程序
      java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点
    • Java
      Java 2021/02/19 .java Main.java 学生.java Bmi.java 。班级 Bmi类 主类 MyBmi.class 学生班 学生样本类 2021/02/20 .java DeleteFile.java WriteFile.java MyDataPrint.java 。班级 DeleteFile.class ...