亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gameframe.java

?? 這是一個經典的五子棋程序能夠人機對戰
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package game;

import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JLabel;
import javax.swing.*;
import javax.swing.border.TitledBorder;

/**
 * <p>Title: 五子棋</p>
 *
 * <p>Description: 五子棋游戲</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: David Company</p>
 *
 * @author David
 * @version 1.0
 */
public class GameFrame extends JFrame {
    JPanel contentPane;
    JMenuBar jMenuBar1 = new JMenuBar();
    JMenu jMenuFile = new JMenu();
    JMenuItem jMenuFileExit = new JMenuItem();
    JMenu jMenuHelp = new JMenu();
    JMenuItem jMenuHelpAbout = new JMenuItem();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel3 = new JPanel();
    JPanel jPanel4 = new JPanel();
    XYLayout xYLayout2 = new XYLayout();
    JLabel jPlayer1 = new JLabel();
    JLabel jPlayer2 = new JLabel();
    XYLayout xYLayout3 = new XYLayout();
    JLabel lBoard = new JLabel();
    XYLayout xYLayout4 = new XYLayout();
    TitledBorder titledBorder1 = new TitledBorder("");
    JPanel jPanel2 = new JPanel();
    JPanel jPanel5 = new JPanel();
    JLabel jLabel4 = new JLabel();
    XYLayout xYLayout5 = new XYLayout();
    XYLayout xYLayout1 = new XYLayout();
    XYLayout xYLayout6 = new XYLayout();
    JLabel jWaitPlayer1 = new JLabel();
    JLabel jWaitPlayer2 = new JLabel();
    JMenu jMenu1 = new JMenu();
    int selectPlayer=0;  //0 - 沒有開始;  1 - Player vs Computer;  2 - Player VS player; 3 - web
    ImageIcon image1;            // 棋盤
    ImageIcon image_bj;          // bj
    ImageIcon image_title;          // title
    ImageIcon image_playing;       // playing
    ImageIcon image_waiting;         // waiting
    ImageIcon image_end;       // end
    ImageIcon jChessImageBlack; // 黑棋子
    ImageIcon jChessImageWhite;// 白棋子

    ImageIcon jImageChess;       // 棋子照片
    JPanel jPanelChess = new JPanel();
    JLabel[] jChess=new JLabel[256];        //  旗子標簽
    int m_step=0;                           //  記錄步數
    private int m_turn=0;                  //  該誰了=0表示黑方,=1白方
    JButton cmd_undo = new JButton();
    int theStep[][]=new int[256][3];
    boolean isFinish=false;                //是否已經成

    NetDialog netDialog;
    Func func=new Func();
    NetGame netgame;
    //下面是一些圖象常量數據
        int linespace=28;
        int xn=15;
        int yn=15;
     //下面數據是調試算法x,y
        int resultX;
        int resultY;
    JMenuItem jMenuItem2 = new JMenuItem();
    JCheckBoxMenuItem jCheckBoxMenuItem1 = new JCheckBoxMenuItem();
    JCheckBoxMenuItem jCheckBoxMenuItem2 = new JCheckBoxMenuItem();
    JMenuItem jMenuItem1 = new JMenuItem();
    int role=-1;
    boolean isWebStart=false;
    int m_undo;
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    XYLayout xYLayout7 = new XYLayout();
    JLabel jLabel3 = new JLabel();
    JLabel jPlayerA = new JLabel();
    JLabel jPlayerB = new JLabel();
    JLabel jLabel5 = new JLabel();
    JButton cmd_New = new JButton();
    public GameFrame() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        //jChessImageBlack = new ImageIcon(game.GameFrame.class.getResource("black.png"));
        //jChessImageWhite = new ImageIcon(game.GameFrame.class.getResource("white.png"));
        image1 = new ImageIcon(game.GameFrame.class.getResource("board.png"));
        image_bj =  new ImageIcon(game.GameFrame.class.getResource("bj.png"));          // bj
        image_title=  new ImageIcon(game.GameFrame.class.getResource("Title.png"));          // title
        image_playing=  new ImageIcon(game.GameFrame.class.getResource("Playing.png"));       // playing
        image_waiting=  new ImageIcon(game.GameFrame.class.getResource("Waiting.png"));         // waiting
        image_end=  new ImageIcon(game.GameFrame.class.getResource("End.png"));         // end
        jChessImageBlack= new ImageIcon(game.GameFrame.class.getResource("black.png")); // 黑棋子
        jChessImageWhite= new ImageIcon(game.GameFrame.class.getResource("white.png"));// 白棋子


        lBoard.setIcon(image1);
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(xYLayout1);
        this.setResizable(false);
        setSize(new Dimension(606, 485));
        setTitle("五子棋游戲");
        jMenuFile.setText("File");
        jMenuFileExit.setText("Exit");
        jMenuFileExit.addActionListener(new
                                        GameFrame_jMenuFileExit_ActionAdapter(this));
        jMenuHelp.setText("Help");
        jMenuHelpAbout.setText("About");
        jMenuHelpAbout.addActionListener(new
                                         GameFrame_jMenuHelpAbout_ActionAdapter(this));
        contentPane.setMinimumSize(new Dimension(606, 485));
        contentPane.setPreferredSize(new Dimension(606, 485));
        jPanel1.setBackground(Color.pink);
        jPanel1.setLayout(xYLayout4);
        jPanel3.setBackground(Color.white);
        jPanel3.setLayout(xYLayout2);
        jPanel4.setLayout(xYLayout3);
        jPlayer1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        jPlayer1.setIcon(jChessImageBlack);
        jPlayer1.setText("Player 1");
        jPlayer2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
        jPlayer2.setIcon(jChessImageWhite);
        jPlayer2.setText("Player 2");
        lBoard.setAlignmentY((float) 0.0);
        lBoard.setBorder(titledBorder1);
        lBoard.setDisabledIcon(null);
        lBoard.setDisplayedMnemonic('0');
        lBoard.setIcon(image1);
        lBoard.setText("");
        lBoard.addMouseListener(new GameFrame_lBoard_mouseAdapter(this));
        jPanel2.setBackground(Color.white);
        jPanel2.setLayout(xYLayout7);
        jPanel5.setLayout(xYLayout5);
        jLabel4.setText("Please Select a Player First");
        jPanelChess.setBackground(Color.cyan);
        jPanelChess.setEnabled(false);
        jPanelChess.setBorder(null);
        jPanelChess.setDoubleBuffered(false);
        jPanelChess.setOpaque(false);
        jPanelChess.setInputVerifier(null);
        jPanelChess.setLayout(xYLayout6);
        cmd_undo.setEnabled(false);
        cmd_undo.setFont(new java.awt.Font("宋體", Font.PLAIN, 12));
        cmd_undo.setToolTipText("");
        cmd_undo.setText("悔棋");
        cmd_undo.addActionListener(new GameFrame_cmd_undo_actionAdapter(this));
        jWaitPlayer1.setFont(new java.awt.Font("Arial", Font.PLAIN, 11));
        jWaitPlayer1.setToolTipText("");
        jWaitPlayer1.setHorizontalAlignment(SwingConstants.CENTER);
        jWaitPlayer1.setText("Stop");
        jWaitPlayer2.setFont(new java.awt.Font("Arial", Font.PLAIN, 11));
        jWaitPlayer2.setToolTipText("");
        jWaitPlayer2.setHorizontalAlignment(SwingConstants.CENTER);
        jWaitPlayer2.setText("Stop");
        jMenu1.setText("Select Player");
        jMenuItem2.setText("New Game");
        jMenuItem2.addActionListener(new GameFrame_jMenuItem2_actionAdapter(this));
        jCheckBoxMenuItem1.setText("Player vs Computer");
        jCheckBoxMenuItem1.addActionListener(new
                GameFrame_jCheckBoxMenuItem1_actionAdapter(this));
        jCheckBoxMenuItem2.setText("Player vs Player");
        jCheckBoxMenuItem2.addActionListener(new
                GameFrame_jCheckBoxMenuItem2_actionAdapter(this));
        jMenuItem1.setText("Network");
        jMenuItem1.addActionListener(new GameFrame_jMenuItem1_actionAdapter(this));
        jLabel1.setIcon(image_bj);
        jLabel1.setText("jLabel1");
        jLabel2.setIcon(image_bj);
        jLabel2.setText("jLabel2");
        jLabel3.setForeground(Color.black);
        jLabel3.setToolTipText("");
        jLabel3.setIcon(image_title);
        jLabel3.setText("jLabel3");
        jPanel5.setBackground(SystemColor.window);
        jPlayerA.setIcon(image_waiting);
        jPlayerA.setText("");
        jPlayerB.setIcon(image_waiting);
        jLabel5.setIcon(image_end);
        jLabel5.setText("");
        cmd_New.addActionListener(new GameFrame_cmd_New_actionAdapter(this));
        cmd_New.setText("New");
        jMenuBar1.add(jMenuFile);
        jMenuFile.add(jMenuItem2);
        jMenuFile.add(jMenu1);
        jMenuFile.addSeparator();
        jMenuFile.add(jMenuFileExit);
        jMenuBar1.add(jMenuHelp);
        jMenuHelp.add(jMenuHelpAbout);
        jPanel1.add(jPanelChess, new XYConstraints(0, 0, -1, -1));  //把棋子層加到jPanel1中
        jPanel1.add(lBoard, new XYConstraints(0, 0, -1, -1));
        jMenu1.add(jCheckBoxMenuItem1);
        jMenu1.add(jCheckBoxMenuItem2);
        jMenu1.add(jMenuItem1);
        jPanel3.add(jPlayer1, new XYConstraints(30, 116, 122, 26));
        jPanel4.add(jPlayer2, new XYConstraints(30, 115, 117, 28));
        contentPane.add(jPanel1, new XYConstraints(0, 0, -1, 431));
        jPanel3.add(jPlayerA, new XYConstraints(49, 18, 70, 67));
        jPanel3.add(jWaitPlayer1, new XYConstraints(52, 83, 58, 17));
        jPanel4.add(jPlayerB, new XYConstraints(49, 18, 70, 67));
        jPanel4.add(jWaitPlayer2, new XYConstraints(52, 83, 58, 17));
        jPanel4.add(jLabel2, new XYConstraints(0, 0, -1, -1));
        contentPane.add(jPanel2, new XYConstraints(435, 0, 166, 77));
        contentPane.add(jPanel3, new XYConstraints(435, 78, 166, 155));
        contentPane.add(jPanel4, new XYConstraints(435, 235, 166, 155));
        contentPane.add(jPanel5, new XYConstraints(435, 392, 166, 39));
        jPanel5.add(jLabel4, new XYConstraints(5, 11, 149, -1));
        jPanel5.add(jLabel5, new XYConstraints(0, 0, -1, -1));
        jPanel2.add(cmd_undo, new XYConstraints(90, 35, 61, 24));
        jPanel2.add(cmd_New, new XYConstraints(18, 35, 63, 24));
        jPanel3.add(jLabel1, new XYConstraints(0, 0, -1, -1));
        jPanel2.add(jLabel3, new XYConstraints(0, 0, -1, -1));
        setJMenuBar(jMenuBar1);
        m_undo=0;
        /*     測試棋子位置
        jImageChess=new ImageIcon(game.GameFrame.class.getResource("black.png"));
        jChess[m_step]=new JLabel();
        jChess[m_step].setIcon(jImageChess);
        jChess[m_step].setAlignmentY((float) 0.0);
        jChess[m_step].setDisabledIcon(null);
        jChess[m_step].setDisplayedMnemonic('0');
        jChess[m_step].setText("");
        jPanelChess.add(jChess[m_step], new XYConstraints(8, 8, 22, 22));
        jChess[m_step]=new JLabel();
     */
    }

    /**
     * File | Exit action performed.
     *
     * @param actionEvent ActionEvent
     */
    void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
        System.exit(0);
    }

    /**
     * Help | About action performed.
     *
     * @param actionEvent ActionEvent
     */
    void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
        GameFrame_AboutBox dlg = new GameFrame_AboutBox(this);
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = getSize();
        Point loc = getLocation();
        dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                        (frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.setModal(true);
        dlg.pack();
        dlg.show();
    }

     //showAllStep is the funcation to show history of theStep[][]
    public void showAllStep(){
        for (int i=1;i<=m_step;i++){
            System.out.print("Step " + i);
            if (theStep[i][2]==0) System.out.print("黑: x=");
            if (theStep[i][2]==1) System.out.print("白: x=");
            System.out.println(theStep[i][0] + " , y=" + theStep[i][1]);
        }
    }

    // writeStep is the funcation to write every step in theStep[][],it can't work,beause 二維數組的操作不對
    private void writeStep(int x,int y,int turn){
        theStep[m_step] = new int[3];
        theStep[m_step][0]=x;
        theStep[m_step][1]=y;
        theStep[m_step][2]=turn;
    }

    private void changePlayer(){
        m_turn=( m_turn + 1 ) % 2;
        if (m_turn == 0 ) {
            jPlayerA.setIcon(image_playing);
            jWaitPlayer1.setText("Playing...");
            jPlayerB.setIcon(image_waiting);
            jWaitPlayer2.setText("Waiting...");
        }
        if (m_turn == 1) {
            jPlayerA.setIcon(image_waiting);
            jWaitPlayer1.setText("Waiting...");
            jPlayerB.setIcon(image_playing);
            jWaitPlayer2.setText("Playing...");
        }
    }

    public synchronized void draw(int i,int j,int turn)  {
        if (turn==0) jImageChess=jChessImageBlack;
        if (turn==1) jImageChess=jChessImageWhite;
        jChess[m_step]=new JLabel();
        jChess[m_step].setIcon(jImageChess);
        jChess[m_step].setAlignmentY((float) 0.0);
        jChess[m_step].setDisabledIcon(null);
        jChess[m_step].setDisplayedMnemonic('0');
        jChess[m_step].setText("");
        jPanelChess.add(jChess[m_step], new XYConstraints(28*j+8, 28*i+8, 22, 22)); //行列 與 XY相反
        jPanelChess.updateUI();
        jPanelChess.revalidate();
    }

    private void showMsg(String msg,String title){
        JOptionPane.showMessageDialog(this,msg,title,JOptionPane.INFORMATION_MESSAGE);
    }

    //解str 到 int[]
    public int[] analys(String str){
             String temp[]=new String[20];
             temp=str.split(":");
             int t[]=new int[20];
             for (int i=0;i<=2;i++)
                 t[i]=Integer.parseInt(temp[i]);
             return t;
  }

    public  void desktop(int x,int y){
        cmd_undo.setEnabled(true);
        if (func.isDrawNow(x, y)) {
            func.setXY(x, y, m_turn);
            m_step++;
            this.writeStep(x, y, m_turn);
            this.showAllStep();
            draw(x, y, m_turn);
            jLabel4.setText("Step: " + m_step + " : " + x + " " + y);
            System.out.println("Player:" + m_turn + " X=" + x + ",Y=" + y);
            changePlayer();
            if (func.isOK()) {
               //public static void showMessageDialog(Component parentComponent,Object message,String title,int messageType,Icon icon)
               String stemp = new String("");
               stemp="恭喜你贏了!";
               if (m_undo!=0) {
                   stemp += "您悔了" + m_undo + "步棋!我不服氣!再來一次!";
               }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
性欧美疯狂xxxxbbbb| 久久91精品久久久久久秒播| 精品嫩草影院久久| 欧美巨大另类极品videosbest| 99久久99精品久久久久久 | 婷婷丁香久久五月婷婷| 亚洲国产高清aⅴ视频| 欧美亚洲免费在线一区| 精品一区二区三区av| 国产精品亚洲成人| 日韩写真欧美这视频| 亚洲日本在线观看| 成人av免费在线观看| 久久婷婷国产综合精品青草| 日韩av中文字幕一区二区三区| 一本色道综合亚洲| 日本一区二区久久| 成人精品视频.| 26uuuu精品一区二区| 天天射综合影视| 欧美丝袜丝交足nylons| 国产精品成人免费| 成人综合婷婷国产精品久久| 国产偷v国产偷v亚洲高清| 精品一区二区三区免费毛片爱| 777亚洲妇女| 首页亚洲欧美制服丝腿| 欧美日韩免费不卡视频一区二区三区| 亚洲视频你懂的| 91色.com| 亚洲精品乱码久久久久| 日本乱码高清不卡字幕| 亚洲老司机在线| 欧美在线观看18| 亚洲国产欧美在线| 欧美色视频在线| 日韩激情av在线| 精品乱人伦小说| 久久成人久久爱| 2023国产精品| 成人av在线观| 一区二区久久久久| 在线看一区二区| 亚洲成av人片在线| 日韩欧美一二三区| 国产精品一区一区| 亚洲欧美一区二区不卡| 欧美日韩一区二区欧美激情| 日本欧美在线观看| 国产亚洲欧洲一区高清在线观看| 国产伦精品一区二区三区免费 | 97超碰欧美中文字幕| 亚洲精品高清视频在线观看| 欧美日韩一区不卡| 久久不见久久见中文字幕免费| 久久精品免视看| 91久久精品午夜一区二区| 亚洲成av人片| 国产欧美日本一区二区三区| 91丨porny丨最新| 喷水一区二区三区| 欧美高清一级片在线观看| 欧美网站大全在线观看| 国产在线精品一区二区夜色 | 成人一级视频在线观看| 亚洲欧美日本韩国| 欧美大片免费久久精品三p| 福利一区福利二区| 日本不卡高清视频| 国产精品久久久久永久免费观看| 欧美日韩一级黄| 成人动漫av在线| 视频在线观看一区| 中文字幕av一区二区三区| 欧美理论电影在线| 成人福利电影精品一区二区在线观看| 水蜜桃久久夜色精品一区的特点| 日本一区二区成人| 欧美tk—视频vk| 日本国产一区二区| 国产精品99久久久| 日韩不卡免费视频| 亚洲国产精品一区二区久久| 国产欧美久久久精品影院| 日韩视频一区二区| 欧美日韩一二区| 色综合久久综合中文综合网| 经典三级一区二区| 五月婷婷欧美视频| 一区二区视频在线| 国产精品乱码一区二三区小蝌蚪| 欧美一区二区三区不卡| 欧美在线视频全部完| av欧美精品.com| 国产精品亚洲成人| 国产精品一区二区无线| 久久99国内精品| 日韩精品福利网| 亚洲高清免费一级二级三级| 亚洲国产激情av| 中文无字幕一区二区三区| 精品国产乱码久久久久久浪潮| 欧美日韩大陆在线| 欧美日韩色综合| 欧美日韩国产一二三| 在线一区二区视频| 欧美视频自拍偷拍| 在线观看日韩av先锋影音电影院| 波多野结衣欧美| www.日韩大片| 一本色道综合亚洲| 欧美性猛交一区二区三区精品 | 国产suv精品一区二区883| 国产在线观看免费一区| 麻豆中文一区二区| 久久国产精品一区二区| 激情六月婷婷综合| 国产麻豆精品在线| 99久久伊人久久99| 色999日韩国产欧美一区二区| 色婷婷久久久久swag精品 | 亚洲第一在线综合网站| 午夜精品福利在线| 日本sm残虐另类| 韩国女主播成人在线| 国产一区不卡精品| 99久久国产综合精品色伊| 91视视频在线观看入口直接观看www| av午夜一区麻豆| 欧美调教femdomvk| 91精品国产综合久久婷婷香蕉 | 国产亚洲成av人在线观看导航| 精品国产一区二区三区忘忧草 | 亚洲综合图片区| 日韩成人一区二区| 国产精品夜夜嗨| 在线观看日韩一区| 日韩欧美在线网站| 国产精品人成在线观看免费 | 欧美色手机在线观看| 欧美一卡2卡3卡4卡| 久久香蕉国产线看观看99| 国产精品国产三级国产aⅴ中文| 一区二区理论电影在线观看| 蜜桃视频在线一区| 国产高清精品久久久久| 97精品久久久久中文字幕| 欧美一区二区三区不卡| 国产精品国产三级国产有无不卡 | 一区二区在线看| 久久国产婷婷国产香蕉| 97久久精品人人做人人爽50路| 91精品综合久久久久久| 欧美韩国日本一区| 日韩电影免费一区| 99精品视频在线播放观看| 日韩亚洲国产中文字幕欧美| 亚洲色图制服诱惑| 激情欧美一区二区| 欧美日韩精品欧美日韩精品| 中文字幕乱码日本亚洲一区二区| 亚洲午夜久久久久久久久久久 | 奇米777欧美一区二区| 欧美日韩一区高清| 久久久国产一区二区三区四区小说| 亚洲精品写真福利| 国产激情精品久久久第一区二区 | 蜜臀久久久久久久| av电影天堂一区二区在线| 日韩欧美一级二级三级| 亚洲午夜激情网站| av亚洲精华国产精华精| 久久夜色精品国产噜噜av| 婷婷久久综合九色综合绿巨人 | 欧美日韩国产首页在线观看| 中文一区二区在线观看| 激情综合五月婷婷| 3d动漫精品啪啪一区二区竹菊| 国产精品麻豆网站| 国产福利91精品一区二区三区| 日韩女优制服丝袜电影| 日韩一区精品字幕| 欧美猛男超大videosgay| 亚洲激情欧美激情| 色先锋资源久久综合| 国产精品久久毛片av大全日韩| 狠狠色综合色综合网络| 日韩亚洲欧美高清| 男女激情视频一区| 在线不卡欧美精品一区二区三区| 一区二区三区中文免费| 91久久精品国产91性色tv | 欧美激情一区二区三区| 国产精品羞羞答答xxdd| 2017欧美狠狠色| 精品一区二区三区久久| 日韩精品一区二区三区swag| 日韩国产高清影视| 欧美一区二区三区视频免费播放| 五月开心婷婷久久|