What do you think?
Hey can someone take a look at this and let me know what they think?
warning it is big
import java.util.*;
import java.io.*;
import java.awt.* ;
import java.awt.event.*;
import javax.swing.*;
publicclass ConnectFourGUIextends JFrameimplements ActionListener{
int gamecounter, col1counter, col2counter, col3counter, col4counter, col5counter, col6counter, col7counter,p1,four,breaker;
int[][] ConnectFourArray =newint[6][7] ;
public String player1,player2;
JButton c1Button;
JButton c2Button;
JButton c3Button;
JButton c4Button;
JButton c5Button;
JButton c6Button;
JButton c7Button;
JButton Start;
JPanel StartPanel;
JPanelBoard;
TextFieldcol01=new TextField(1);
TextFieldcol02=new TextField(1);
TextFieldcol03=new TextField(1);
TextFieldcol04=new TextField(1);
TextFieldcol05=new TextField(1);
TextFieldcol06=new TextField(1);
JPanelColumn0;
TextFieldcol11=new TextField(1);
TextFieldcol12=new TextField(1);
TextFieldcol13=new TextField(1);
TextFieldcol14=new TextField(1);
TextFieldcol15=new TextField(1);
TextFieldcol16=new TextField(1);
JPanelColumn1;
TextFieldcol21=new TextField(1);
TextFieldcol22=new TextField(1);
TextFieldcol23=new TextField(1);
TextFieldcol24=new TextField(1);
TextFieldcol25=new TextField(1);
TextFieldcol26=new TextField(1);
JPanelColumn2;
TextFieldcol31=new TextField(1);
TextFieldcol32=new TextField(1);
TextFieldcol33=new TextField(1);
TextFieldcol34=new TextField(1);
TextFieldcol35=new TextField(1);
TextFieldcol36=new TextField(1);
JPanelColumn3;
TextFieldcol41=new TextField(1);
TextFieldcol42=new TextField(1);
TextFieldcol43=new TextField(1);
TextFieldcol44=new TextField(1);
TextFieldcol45=new TextField(1);
TextFieldcol46=new TextField(1);
JPanelColumn4;
TextFieldcol51=new TextField(1);
TextFieldcol52=new TextField(1);
TextFieldcol53=new TextField(1);
TextFieldcol54=new TextField(1);
TextFieldcol55=new TextField(1);
TextFieldcol56=new TextField(1);
JPanelColumn5;
TextFieldcol61=new TextField(1);
TextFieldcol62=new TextField(1);
TextFieldcol63=new TextField(1);
TextFieldcol64=new TextField(1);
TextFieldcol65=new TextField(1);
TextFieldcol66=new TextField(1);
JPanelColumn6;
JPanel SelectColumn;
JPanel SelectPanel;
JLabel Welcome;
public ConnectFourGUI(){
setTitle("Connect Four" );
setDefaultCloseOperation( EXIT_ON_CLOSE );
c1Button =new JButton("1");
c2Button =new JButton("2");
c3Button =new JButton("3");
c4Button =new JButton("4");
c5Button =new JButton("5");
c6Button =new JButton("6");
c7Button =new JButton("7");
Start=new JButton("Start");
SelectColumn =new JPanel();
SelectColumn.setLayout(
new BoxLayout( SelectColumn, BoxLayout.X_AXIS ) );
SelectColumn.add(new JLabel("Select A Column") );
SelectColumn.add( c1Button ); SelectColumn.add( c2Button );
SelectColumn.add( c3Button );SelectColumn.add( c4Button );
SelectColumn.add( c5Button );SelectColumn.add( c6Button );
SelectColumn.add( c7Button );
c1Button.setActionCommand("1");
c2Button.setActionCommand("2");
c3Button.setActionCommand("3");
c4Button.setActionCommand("4");
c5Button.setActionCommand("5");
c6Button.setActionCommand("6");
c7Button.setActionCommand("7");
Start.setActionCommand("Start");
SelectColumn.add(c1Button);
SelectColumn.add(c2Button);
SelectColumn.add(c3Button);
SelectColumn.add(c4Button);
SelectColumn.add(c5Button);
SelectColumn.add(c6Button);
SelectColumn.add(c7Button);
//*************************COLUMNS*************************************
// column0
Column0 =new JPanel();
Column0.setLayout(new BoxLayout( Column0, BoxLayout.Y_AXIS ) );
Column0.add(new JLabel("Column 1") );
Column0.add(col01);Column0.add(col02);Column0.add(col03);
Column0.add(col04);Column0.add(col05);Column0.add(col06);
col01.setEditable(false );col02.setEditable(false );
col03.setEditable(false );col04.setEditable(false );
col05.setEditable(false );col06.setEditable(false );
Column1 =new JPanel();
Column1.setLayout(new BoxLayout( Column1, BoxLayout.Y_AXIS ) );
Column1.add(new JLabel("Column 2") );
Column1.add(col11);Column1.add(col12);Column1.add(col13);
Column1.add(col14);Column1.add(col15);Column1.add(col16);
col11.setEditable(false );col12.setEditable(false );
col13.setEditable(false );col14.setEditable(false );
col15.setEditable(false );col16.setEditable(false );
Column2 =new JPanel();
Column2.setLayout(new BoxLayout( Column2, BoxLayout.Y_AXIS ) );
Column2.add(new JLabel("Column 3") );
Column2.add(col21);Column2.add(col22);Column2.add(col23);
Column2.add(col24);Column2.add(col25);Column2.add(col26);
col21.setEditable(false );col22.setEditable(false );
col23.setEditable(false );col24.setEditable(false );
col25.setEditable(false );col26.setEditable(false );
Column3 =new JPanel();
Column3.setLayout(new BoxLayout( Column3, BoxLayout.Y_AXIS ) );
Column3.add(new JLabel("Column 4") );
Column3.add(col31);Column3.add(col32);Column3.add(col33);
Column3.add(col34);Column3.add(col35);Column3.add(col36);
col31.setEditable(false );col32.setEditable(false );
col33.setEditable(false );col34.setEditable(false );
col35.setEditable(false );col36.setEditable(false );
Column4 =new JPanel();
Column4 =new JPanel();
Column4.setLayout(new BoxLayout( Column4, BoxLayout.Y_AXIS ) );
Column4.add(new JLabel("Column 5") );
Column4.add(col41);Column4.add(col42);Column4.add(col43);
Column4.add(col44);Column4.add(col45);Column4.add(col46);
col41.setEditable(false );col42.setEditable(false );
col43.setEditable(false );col44.setEditable(false );
col45.setEditable(false );col46.setEditable(false );
Column5 =new JPanel();
Column5.setLayout(new BoxLayout( Column5, BoxLayout.Y_AXIS ) );
Column5.add(new JLabel("Column 6") );
Column5.add(col51);Column5.add(col52);Column5.add(col53);
Column5.add(col54);Column5.add(col55);Column5.add(col56);
col51.setEditable(false );col52.setEditable(false );
col53.setEditable(false );col54.setEditable(false );
col55.setEditable(false );col56.setEditable(false );
Column6 =new JPanel();
Column6.setLayout(new BoxLayout( Column6, BoxLayout.Y_AXIS ) );
Column6.add(new JLabel("Column 7") );
Column6.add(col61);Column6.add(col62);Column6.add(col63);
Column6.add(col64);Column6.add(col65);Column6.add(col66);
col61.setEditable(false );col62.setEditable(false );
col63.setEditable(false );col64.setEditable(false );
col65.setEditable(false );col66.setEditable(false );
//*************************************************************************
Board=new JPanel();
Board.setLayout(new BoxLayout( Board, BoxLayout.X_AXIS) );
Board.add(Column0);Board.add(Column1);Board.add(Column2);Board.add(Column3);
Board.add(Column4);Board.add(Column5);Board.add(Column6);
c1Button.addActionListener(this );
c2Button.addActionListener(this );
c3Button.addActionListener(this );
c4Button.addActionListener(this );
c5Button.addActionListener(this );
c6Button.addActionListener(this );
c7Button.addActionListener(this );
Start.addActionListener(this );
getContentPane().setLayout(new BorderLayout() );
getContentPane().add( Start, BorderLayout.NORTH );
getContentPane().add( Board, BorderLayout.CENTER );
getContentPane().add( SelectColumn, BorderLayout.SOUTH );
}
publicvoid actionPerformed( ActionEvent evt){
if(evt.getActionCommand().equals("Start")){
player1=JOptionPane.showInputDialog("Player 1 Enter Your Name");
player2=JOptionPane.showInputDialog("Player 2 Enter Your Name");
}
gamecounter=gamecounter+1;
p1=gamecounter%2;
//*************** Ga ***************
if(p1==0){
if(evt.getActionCommand().equals("1")){
col1counter=col1counter+1;
if (col1counter==1){
col06.setBackground(Color.red);
ConnectFourArray[5][0]=1;
}
elseif (col1counter==2){
col05.setBackground(Color.red);
ConnectFourArray[4][0]=1;
}
elseif (col1counter==3){
col04.setBackground(Color.red);
ConnectFourArray[3][0]=1;
}
elseif (col1counter==4){
col03.setBackground(Color.red);
ConnectFourArray[2][0]=1;
}
elseif (col1counter==5){
col02.setBackground(Color.red);
ConnectFourArray[1][0]=1;
}
else{
col01.setBackground(Color.red);
ConnectFourArray[0][0]=1;
}
}
if(evt.getActionCommand().equals("2")){
col2counter=col2counter+1;
if (col2counter==1){
col16.setBackground(Color.red);
ConnectFourArray[5][1]=1;
}
elseif (col2counter==2){
col15.setBackground(Color.red);
ConnectFourArray[4][1]=1;
}
elseif (col2counter==3){
col14.setBackground(Color.red);
ConnectFourArray[3][1]=1;
}
elseif (col2counter==4){
col13.setBackground(Color.red);
ConnectFourArray[2][1]=1;
}
elseif (col2counter==5){
col12.setBackground(Color.red);
ConnectFourArray[1][1]=1;
}
else{
col11.setBackground(Color.red);
ConnectFourArray[0][1]=1;
}
}
if(evt.getActionCommand().equals("3")){
col3counter=col3counter+1;
if (col3counter==1){
col26.setBackground(Color.red);
ConnectFourArray[5][2]=1;
}
elseif (col3counter==2){
col25.setBackground(Color.red);
ConnectFourArray[4][2]=1;
}
elseif (col3counter==3){
col24.setBackground(Color.red);
ConnectFourArray[3][2]=1;
}
elseif (col3counter==4){
col23.setBackground(Color.red);
ConnectFourArray[2][2]=1;
}
elseif (col3counter==5){
col22.setBackground(Color.red);
ConnectFourArray[1][2]=1;
}
else{
col21.setBackground(Color.red);
ConnectFourArray[0][2]=1;
}
}
if(evt.getActionCommand().equals("4")){
col4counter=col4counter+1;
if (col4counter==1){
col36.setBackground(Color.red);
ConnectFourArray[5][3]=1;
}
elseif (col4counter==2){
col35.setBackground(Color.red);
ConnectFourArray[4][3]=1;
}
elseif (col4counter==3){
col34.setBackground(Color.red);
ConnectFourArray[3][3]=1;
}
elseif (col4counter==4){
col33.setBackground(Color.red);
ConnectFourArray[2][3]=1;
}
elseif (col4counter==5){
col32.setBackground(Color.red);
ConnectFourArray[1][3]=1;
}
else{
col31.setBackground(Color.red);
ConnectFourArray[0][3]=1;
}
}
if(evt.getActionCommand().equals("5")){
col5counter=col5counter+1;
if (col5counter==1){
col46.setBackground(Color.red);
ConnectFourArray[5][4]=1;
}
elseif (col5counter==2){
col45.setBackground(Color.red);
ConnectFourArray[4][4]=1;
}
elseif (col5counter==3){
col44.setBackground(Color.red);
ConnectFourArray[3][4]=1;
}
elseif (col5counter==4){
col43.setBackground(Color.red);
ConnectFourArray[2][4]=1;
}
elseif (col5counter==5){
col42.setBackground(Color.red);
ConnectFourArray[1][4]=1;
}
else{
col41.setBackground(Color.red);
ConnectFourArray[0][4]=1;
}
}
if(evt.getActionCommand().equals("6")){
col6counter=col6counter+1;
if (col6counter==1){
col56.setBackground(Color.red);
ConnectFourArray[5][5]=1;
}
elseif (col6counter==2){
col55.setBackground(Color.red);
ConnectFourArray[4][5]=1;
}
elseif (col6counter==3){
col54.setBackground(Color.red);
ConnectFourArray[3][5]=1;
}
elseif (col6counter==4){
col53.setBackground(Color.red);
ConnectFourArray[2][5]=1;
}
elseif (col6counter==5){
col52.setBackground(Color.red);
ConnectFourArray[1][5]=1;
}
else{
col51.setBackground(Color.red);
ConnectFourArray[0][5]=1;
}
}
if(evt.getActionCommand().equals("7")){
col7counter=col7counter+1;
if (col7counter==1){
col66.setBackground(Color.red);
ConnectFourArray[5][6]=1;
}
elseif (col7counter==2){
col65.setBackground(Color.red);
ConnectFourArray[4][6]=1;
}
elseif (col7counter==3){
col64.setBackground(Color.red);
ConnectFourArray[3][6]=1;
}
elseif (col7counter==4){
col63.setBackground(Color.red);
ConnectFourArray[2][6]=1;
}
elseif (col7counter==5){
col62.setBackground(Color.red);
ConnectFourArray[1][6]=1;
}
else{
col61.setBackground(Color.red);
ConnectFourArray[0][6]=1;
}
}
}
//****************** Rawr Player 2 **************
else{
if(evt.getActionCommand().equals("1")){
col1counter=col1counter+1;
if (col1counter==1){
col06.setBackground(Color.black);
ConnectFourArray[5][0]=2;
}
elseif (col1counter==2){
col05.setBackground(Color.black);
ConnectFourArray[4][0]=2;
}
elseif (col1counter==3){
col04.setBackground(Color.black);
ConnectFourArray[3][0]=2;
}
elseif (col1counter==4){
col03.setBackground(Color.black);
ConnectFourArray[2][0]=2;
}
elseif (col1counter==5){
col02.setBackground(Color.black);
ConnectFourArray[1][0]=2;
}
else{
col01.setBackground(Color.black);
ConnectFourArray[0][0]=2;
}
}
if(evt.getActionCommand().equals("2")){
col2counter=col2counter+1;
if (col2counter==1){
col16.setBackground(Color.black);
ConnectFourArray[5][1]=2;
}
elseif (col2counter==2){
col15.setBackground(Color.black);
ConnectFourArray[4][1]=2;
}
elseif (col2counter==3){
col14.setBackground(Color.black);
ConnectFourArray[3][1]=2;
}
elseif (col2counter==4){
col13.setBackground(Color.black);
ConnectFourArray[2][1]=2;
}
elseif (col2counter==5){
col12.setBackground(Color.black);
ConnectFourArray[1][1]=2;
}
else{
col11.setBackground(Color.black);
ConnectFourArray[0][1]=2;
}
}
if(evt.getActionCommand().equals("3")){
col3counter=col3counter+1;
if (col3counter==1){
col26.setBackground(Color.black);
ConnectFourArray[5][2]=2;
}
elseif (col3counter==2){
col25.setBackground(Color.black);
ConnectFourArray[4][2]=2;
}
elseif (col3counter==3){
col24.setBackground(Color.black);
ConnectFourArray[3][2]=2;
}
elseif (col3counter==4){
col23.setBackground(Color.black);
ConnectFourArray[2][2]=2;
}
elseif (col3counter==5){
col22.setBackground(Color.black);
ConnectFourArray[1][2]=2;
}
else{
col21.setBackground(Color.black);
ConnectFourArray[0][2]=2;
}
}
if(evt.getActionCommand().equals("4")){
col4counter=col4counter+1;
if (col4counter==1){
col36.setBackground(Color.black);
ConnectFourArray[5][3]=2;
}
elseif (col4counter==2){
col35.setBackground(Color.black);
ConnectFourArray[4][3]=2;
}
elseif (col4counter==3){
col34.setBackground(Color.black);
ConnectFourArray[3][3]=2;
}
elseif (col4counter==4){
col33.setBackground(Color.black);
ConnectFourArray[2][3]=2;
}
elseif (col4counter==5){
col32.setBackground(Color.black);
ConnectFourArray[1][3]=2;
}
else{
col31.setBackground(Color.black);
ConnectFourArray[0][3]=2;
}
}
if(evt.getActionCommand().equals("5")){
col5counter=col5counter+1;
if (col5counter==1){
col46.setBackground(Color.black);
ConnectFourArray[5][4]=2;
}
elseif (col5counter==2){
col45.setBackground(Color.black);
ConnectFourArray[4][4]=2;
}
elseif (col5counter==3){
col44.setBackground(Color.black);
ConnectFourArray[3][4]=2;
}
elseif (col5counter==4){
col43.setBackground(Color.black);
ConnectFourArray[2][4]=2;
}
elseif (col5counter==5){
col42.setBackground(Color.black);
ConnectFourArray[1][4]=2;
}
else{
col41.setBackground(Color.black);
ConnectFourArray[0][4]=2;
}
}
if(evt.getActionCommand().equals("6")){
col6counter=col6counter+1;
if (col6counter==1){
col56.setBackground(Color.black);
ConnectFourArray[5][5]=2;
}
elseif (col6counter==2){
col55.setBackground(Color.black);
ConnectFourArray[4][5]=2;
}
elseif (col6counter==3){
col54.setBackground(Color.black);
ConnectFourArray[3][5]=2;
}
elseif (col6counter==4){
col53.setBackground(Color.black);
ConnectFourArray[2][5]=2;
}
elseif (col6counter==5){
col52.setBackground(Color.black);
ConnectFourArray[1][5]=2;
}
else{
col51.setBackground(Color.black);
ConnectFourArray[0][5]=2;
}
}
if(evt.getActionCommand().equals("7")){
col7counter=col7counter+1;
if (col7counter==1){
col66.setBackground(Color.black);
ConnectFourArray[5][6]=2;
}
elseif (col7counter==2){
col65.setBackground(Color.black);
ConnectFourArray[4][6]=2;
}
elseif (col7counter==3){
col64.setBackground(Color.black);
ConnectFourArray[3][6]=2;
}
elseif (col7counter==4){
col63.setBackground(Color.black);
ConnectFourArray[2][6]=2;
}
elseif (col7counter==5){
col62.setBackground(Color.black);
ConnectFourArray[1][6]=2;
}
else{
col61.setBackground(Color.black);
ConnectFourArray[0][6]=2;
}
}
}
if(col1counter>5){
c1Button.setEnabled(false );
}
if(col2counter>5){
c2Button.setEnabled(false );
}
if(col3counter>5){
c3Button.setEnabled(false );
}
if(col4counter>5){
c4Button.setEnabled(false );
}
if(col5counter>5){
c5Button.setEnabled(false );
}
if(col6counter>5){
c6Button.setEnabled(false );
}
if(col7counter>5){
c7Button.setEnabled(false );
}
repaint();
//*********************PLAYER 1 HORIZONTAL********************************************
for (int numrows=0;numrows<ConnectFourArray.length;numrows++){
four=0;
for (int numcols=0; numcols><ConnectFourArray[(numrows)].length;numcols++){
if (ConnectFourArray[numrows][numcols]==1){
four=four+1;
}
else{
four=0;
}
if(four==4){
System.out.println(player1+" wins");
breaker=4;
break;
}
}
}
//***************************PLAYER 1 VERTICAL***********************************************************************
for (int numcols=0;numcols<(ConnectFourArray.length+1);numcols++){
if (four==3){
break;
}
four=0;
for (int numrows=0; numrows><ConnectFourArray.length;numrows++){
if (ConnectFourArray[numrows][numcols]==1){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player1+" wins");
breaker=4;
break;
}
}
}
//*********************PLAYER 1 DIAGONAL RIGHT (COLUMN 1)*****************************************************
int maxcol=6;
int counter=1;
for (int left=ConnectFourArray.length;left>1;left--){
four=0;
int numrows=6;
numrows=numrows-counter;
int numcols=0;
for (int num=0; num<maxcol;num++){
if (ConnectFourArray[numrows][numcols]==1){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player1+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols+1;
}
counter=counter+1;
//numcols=numcols+1;
maxcol=maxcol-1;
}
//**************************PLAYER 1 DIAGONAL RIGHT (ROW 1)*******************************************
int maxcol2=6;
int counter2=1;
for (int left=ConnectFourArray.length;left>0;left--){
four=0;
int numrows=5;
int numcols;
numcols=0;
numcols=numcols+counter2;
for (int num=0; num<maxcol2;num++){
if (ConnectFourArray[numrows][numcols]==1){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player1+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols+1;
}
counter2=counter2+1;
maxcol2=maxcol2-1;
}
//*********************PLAYER 1 DIAGONAL LEFT (COLUMN 1)*****************************************************
int maxcol5=6;
int counter5=1;
for (int left=ConnectFourArray.length;left>1;left--){
four=0;
int numrows=6;
numrows=numrows-counter5;
int numcols=5;
for (int num=0; num<maxcol5;num++){
if (ConnectFourArray[numrows][numcols]==1){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(four);
System.out.println(player1+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols-1;
}
counter5=counter5+1;
maxcol5=maxcol5-1;
}
//**************************PLAYER 1 DIAGONAL LEFT (ROW 1)*******************************************
int maxcol4=6;
int counter4=0;
for (int left=ConnectFourArray.length;left>0;left--){
four=0;
int numrows=5;
int numcols;
numcols=5;
numcols=numcols-counter4;
for (int num=0; num<maxcol4;num++){
if (ConnectFourArray[numrows][numcols]==1){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player1+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols-1;
}
counter4=counter4+1;
maxcol4=maxcol4-1;
}
//*************************************************************************************************************
//********************************PLAYER 2 HORIZONTAL*********************************
for (int numrows=0;numrows<ConnectFourArray.length;numrows++){
four=0;
for (int numcols=0; numcols><ConnectFourArray[(numrows)].length;numcols++){
if (ConnectFourArray[numrows][numcols]==2){
four=four+1;
}
else{
four=0;
}
if(four==4){
System.out.println(player2+" wins");
breaker=4;
break;
}
}
}
//***************************************PLAYER 2 VERTICAL***********************************************************
for (int numcols=0;numcols<(ConnectFourArray.length+1);numcols++){
if (four==3){
break;
}
four=0;
for (int numrows=0; numrows><ConnectFourArray.length;numrows++){
if (ConnectFourArray[numrows][numcols]==2){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player2+" wins");
breaker=4;
break;
}
}
}
//*********************PLAYER 2 DIAGONAL RIGHT (COLUMN 1)*****************************************************
int maxcol1=6;
int counter1=1;
for (int left=ConnectFourArray.length;left>1;left--){
four=0;
int numrows=6;
numrows=numrows-counter1;
int numcols=0;
for (int num=0; num<maxcol1;num++){
if (ConnectFourArray[numrows][numcols]==2){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player2+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols+1;
}
counter1=counter1+1;
maxcol1=maxcol1-1;
}
//**************************PLAYER 2 DIAGONAL RIGHT (ROW 1)*******************************************
int maxcol3=6;
int counter3=1;
for (int left=ConnectFourArray.length;left>0;left--){
four=0;
int numrows=5;
int numcols;
numcols=0;
numcols=numcols+counter3;
for (int num=0; num<maxcol3;num++){
if (ConnectFourArray[numrows][numcols]==2){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player2+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols+1;
}
counter3=counter3+1;
maxcol3=maxcol3-1;
}
//*********************PLAYER 2 DIAGONAL LEFT (COLUMN 1)*****************************************************
int maxcol6=6;
int counter6=1;
for (int left=ConnectFourArray.length;left>1;left--){
four=0;
int numrows=6;
numrows=numrows-counter6;
int numcols=5;
for (int num=0; num<maxcol6;num++){
if (ConnectFourArray[numrows][numcols]==2){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(four);
System.out.println(player2+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols-1;
}
counter6=counter6+1;
maxcol6=maxcol6-1;
}
//**************************PLAYER 2 DIAGONAL LEFT (ROW 1)*******************************************
int maxcol7=6;
int counter7=0;
for (int left=ConnectFourArray.length;left>0;left--){
four=0;
int numrows=5;
int numcols;
numcols=5;
numcols=numcols-counter7;
for (int num=0; num<maxcol7;num++){
if (ConnectFourArray[numrows][numcols]==2){
four=four+1;
}
else{
four=0;
}
if (four==4){
System.out.println(player2+" wins");
breaker=4;
break;
}
numrows=numrows-1;
numcols=numcols-1;
}
counter7=counter7+1;
maxcol7=maxcol7-1;
}
//*****************************************************************************************************************
if (breaker==4){
System.exit(0);
}
}
publicstaticvoid main ( String[] args ){
ConnectFourGUI connection =new ConnectFourGUI() ;
connection.setSize( 500, 400 );
connection.setVisible(true );
}
}
>

