packageBlackWhite;importjava.awt.BorderLayout;importjava.awt.FlowLayout;importjava.awt.GridLayout;importjava.awt.Insets;importjava.awt.event.MouseEvent;importjava.awt.event.MouseListener;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;public classGame {private JFrame mainWindow;//JFrame是顶层容器
private JPanel centerPanel;//放置棋盘
private JPanel sourthPanel;//信息提示框
privateJLabel playInforLabel_1;privateJLabel playInforLabel_2;privateJButton newGameButton;private Insets margins=new Insets(0,0,0,0);private static JButton[][] buttonArray=new MyButton[25][25];private int type=1;//1黑2白
private boolean isWin=false;publicGame() {
mainWindow=new JFrame("五子棋");
mainWindow.setLayout(newBorderLayout());
mainWindow.setSize(600, 750);
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWindow.setResizable(false);
centerPanel=newJPanel();
centerPanel.setLayout(new GridLayout(25,25));for(int y=0;y
buttonArray[y][x]=newMyButton(y,x);
buttonArray[y][x].setText("");
buttonArray[y][x].setMargin(margins);//myButtonAddEvent((MyButton) buttonArray[y][x]);
centerPanel.add(buttonArray[y][x]);
}
}
sourthPanel=newJPanel();
sourthPanel.setLayout(newFlowLayout());
playInforLabel_1=new JLabel("黑方下棋&#