⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwin.java

📁 java开发的人机对战五子棋游戏!只有安装jdk环境,就可以运行
💻 JAVA
字号:


import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.*;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;

public class MainWin extends JFrame implements ActionListener,MouseListener{
    public MainWin() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void jbInit() throws Exception {

        contentPane = (JPanel) getContentPane();
        setTitle("五子棋人机对战游戏");
        setBounds(200,100,680,550);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        contentPane.setLayout(null);
        showsys.setBackground(new Color(212, 208, 230));
        showsys.setBounds(new Rectangle(540, 0, 130, 520));
        showsys.setLayout(null);
        showfive.setBackground(new Color(212, 184, 200));
        showfive.setBounds(new Rectangle(0, 0, 520, 520));
        showfive.setLayout(null);
        contentPane.setBounds(10, 10, 600, 580);
        contentPane.setBorder(null);
        contentPane.setBounds(new Rectangle(10, 10, 500, 400));
        startgame.setBounds(new Rectangle(25, 5, 83, 27));
        startgame.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        startgame.setText("开始游戏");
        startgame.addActionListener(this);
        jScrollPane1.setBounds(new Rectangle(9, 88, 116, 296));
        fivechess.setBounds(0, 0, 520, 520);
        contentPane.add(showfive, null);
        contentPane.add(showsys, null);
        showsys.add(startgame);
        showsys.add(jScrollPane1);
        jScrollPane1.getViewport().add(showmsg);
        showfive.add(fivechess, null);
        setResizable(false);
        setVisible(true);
    }
    public void actionPerformed(ActionEvent e)
    {
//        if(e.getSource()==startgame)
        StartGame();
    }
    public void mouseReleased(MouseEvent e)
    {

    }
    public void mousePressed(MouseEvent e)
    {

    }
    public void mouseEntered(MouseEvent e)
    {

    }
    public void mouseExited(MouseEvent e)
    {

    }
    public void  mouseClicked(MouseEvent e)
    {
    }
    public void showmsg(String msg){
        showmsg.append(msg+"\n");
    }
    public void showmsg(int i){
        showmsg.append(i+"\n");
    }
    public void showmsg(){
        showmsg.append("\n");
    }

    public void StartGame()
    {
       showmsg.append("游戏开始\n");

    }
    JPanel contentPane;
    JPanel showfive = new JPanel();
    JPanel showsys = new JPanel();
    JLabel fivechess = new JLabel(new ImageIcon("chessdesk.png"));
    JButton startgame = new JButton();
    JScrollPane jScrollPane1 = new JScrollPane();
    JTextArea showmsg = new JTextArea();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -