Hi I'm doing a project in java.It is the game othello.It was all going well till i got an ArrayOutOfBoundsException. the array is this buttons[9][9]; If you dont know othello it's a board game with an 8x8 board.

The Exact error is "ArrayOutOfBoundsException: 9" and give the lines which the error is which are:

1->

if (the_buttons[rows][colunm+1].getIcon().equals(BG)== true &&
                  the_buttons[rows+1][colunm].getIcon().equals(BG)== true &&
	  the_buttons[rows][colunm-1].getIcon().equals(BG)== true && 
	  the_buttons[rows-1][colunm].getIcon().equals(BG)== true )
	       {
		dialog(2);
		return false;
	        }		 
    return true;

2->

if(checkIfOccupied() == false && checkForSq()== true )
		   {
		          if(checkIflegal()==true)
		            {
			 if (checkWhichPlayer()==true)
          			     { 							                          the_buttons[rows][colunm].setIcon(r);
				 checkForward(r,Y)  ;
				 checkUpLeft(r,Y)   ;
				 checkUpRight(r,Y)  ;
			            	 checkBackwards(r,Y);
			            	 checkDownLeft(r,Y) ;
			             	 checkDownRight(r,Y);
			             	 checkDown(r,Y)     ;
			                 checkUp(r,Y)       ;
	   		     }

3->

if (cmd.equals(""+i))
	    {
	              checkforColunm(j=0,i);
	             PickButton(rows,colunm);
                            
                      }

CAN ANYONE HELP IT'S THE LAST HURDEL AND THIS NEEDS TO BE IN TOMORROW.....

you are exceeding the array's bounds.
exactly, one can't figure out what causes the error, because the manipulation is done by
your code that comes before these blocks.
check it again, either you go beyond index 8 or below index 0, good luck.

I'm Sorry to do this but I really need help with this I'm posting my project so far to see if you can help

Attachments
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import java.lang.*;




public class othello extends JFrame implements ActionListener
{

	   
		ImageIcon        temp,tempO;
		ImageIcon        BG,r,Y;
		GridLayout		 gl;
		BorderLayout	 bl;
		Panel			 info,Board,Blank,Blank2;
		TextField		 score[];
		Label			 label[];
		JButton		     the_buttons[][];
		JButton          start;
		String           red = "RED",yellow ="YELLOW",string;
        int				 i,j=1,n_buttons =8;
		int              rows,colunm,tempC =0,tempR=0;
		int              Rstart,Cstart;
		int				 player =1;
		int				 redButtons,YellowButtons,pressed=1;
        boolean          found = false;

public othello(){

		
		the_buttons = new JButton[9][9];
        info        = new Panel();
		Blank       = new Panel();
		Blank2      = new Panel();
		Board       = new Panel();
		score       = new TextField[2];
		label       = new Label[2];
		gl          = new GridLayout(8,8);
		bl          = new BorderLayout();
		BG          = new ImageIcon("Ablue.gif",""+i);
        r           = new ImageIcon("RedC.gif",""+i);
		Y           = new ImageIcon("YellowC.gif",""+i);
        start       = new JButton("start");
        score[0]	= new TextField(" " + redButtons);
		score[1]	= new TextField(" " + YellowButtons);
		label[0]	= new Label(red);
		label[1]	= new Label(yellow);
		
		setLayout(bl);
		Board.setLayout(gl);
		info.setLayout(gl);
		score[0].setEditable(false);
		score[1].setEditable(false);
		start.addActionListener(this);
	
		Blank.setBackground(Color.black);
		Blank2.setBackground(Color.black);
		
		 info.add(label[0]);
		 info.add(score[0]);
		 info.add(score[1]);
		 info.add(label[1]);
		 info.add(start);

		add("North",Blank2);
	    add("East",info);
		add("Center",Board);
		add("South",Blank);
		
		
	
	

		
		
        	
	
	for(i=1 ;i < 9; i++ )
		  {
		   
				the_buttons[1][i] = new JButton(""+j,BG); j++;
				the_buttons[2][i] = new JButton(""+j,BG); j++;
				the_buttons[3][i] = new JButton(""+j,BG); j++;
				the_buttons[4][i] = new JButton(""+j,BG); j++;
				the_buttons[5][i] = new JButton(""+j,BG); j++;
				the_buttons[6][i] = new JButton(""+j,BG); j++;
				the_buttons[7][i] = new JButton(""+j,BG); j++;
				the_buttons[8][i] = new JButton(""+j,BG); j++;
				
				the_buttons[1][i].addActionListener(this);
				the_buttons[2][i].addActionListener(this);
				the_buttons[3][i].addActionListener(this);
				the_buttons[4][i].addActionListener(this);
				the_buttons[5][i].addActionListener(this);
				the_buttons[6][i].addActionListener(this);
				the_buttons[7][i].addActionListener(this);
				the_buttons[8][i].addActionListener(this);
				Board.add(the_buttons[1][i]);
				Board.add(the_buttons[2][i]);
				Board.add(the_buttons[3][i]);
				Board.add(the_buttons[4][i]);
				Board.add(the_buttons[5][i]);
				Board.add(the_buttons[6][i]);
				Board.add(the_buttons[7][i]);
				Board.add(the_buttons[8][i]);
	           }

		    
			the_buttons[5][4].setIcon(r);
			the_buttons[4][5].setIcon(r);
	            the_buttons[4][4].setIcon(Y);
	       	the_buttons[5][5].setIcon(Y);
			
           
	
	}


	
public int countRed()
{
	for (i=0 ; i < 9 ;i++ )
	{
		
		if(the_buttons[i][i].getIcon().equals(r))
			redButtons ++;
		
	}System.out.println("Red Button: "+ redButtons);
	return redButtons;
}


public int countYellow()
{
	for (i=0 ; i < 9 ;i++ )
	{
		
		if(the_buttons[i][i].getIcon().equals(Y))
			YellowButtons ++;
				
	}System.out.println("Yellow Button: "+ YellowButtons);
	return YellowButtons;
}


public void actionPerformed(ActionEvent event){
		
		
		String cmd = event.getActionCommand(); //get the ActionCommand
		

		

				for (int i =1 ;i < 64 ;i++ )
				{
				   pressed++;
				
					if (cmd.equals(""+i))
						{
							 checkforColunm(j=0,i);
							 PickButton(rows,colunm);
                            
							
                        }
				
			}
			
}


public void  checkForward(ImageIcon temp,ImageIcon tempO)
	{
		int limit=0;
		int Rstart = rows;
		     tempR = rows;

		do
		{
			tempR++;
			limit++;
		}
		while (the_buttons[tempR][colunm].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][colunm].setIcon(temp);
					Rstart++;
					if(the_buttons[tempR][colunm].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][colunm].getIcon().equals(BG)==true)
							  {break;}
				}				
							
			
	}


	public void  checkBackwards(ImageIcon temp,ImageIcon tempO)
	{
	    int limit=0;
		Rstart = rows;
		tempR = rows;

		do
		{
			tempR--;
			limit++;
		}
		while (the_buttons[tempR][colunm].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][colunm].setIcon(temp);
					Rstart--;
					if(the_buttons[tempR][colunm].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][colunm].getIcon().equals(BG)==true)
							  {break;}
				}				
					
	   	
	}


	public void  checkDownLeft(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Rstart = rows;
		 Cstart = colunm;
		 tempR = rows;
         tempC = colunm;
		
		do
		{
			tempR--;
			tempC++;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Rstart--;
					Cstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}				
					

	}


	public void  checkDownRight(ImageIcon temp,ImageIcon tempO)
	{
	 
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		do
		{
			tempR++;
			tempC++;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart++;
					Rstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}

	}


public void  checkDown(ImageIcon temp,ImageIcon tempO)
	{
	   		    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		
		do
		{
			
			tempC++;
			limit++;
		}
		while (the_buttons[rows][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[rows][Cstart].setIcon(temp);
					Cstart++;
					if(the_buttons[rows][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[rows][tempC].getIcon().equals(BG)==true)
							  {break;}
				}				
					

	}

public void  checkUpLeft(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		
		do
		{
			tempR++;
			tempC--;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart--;
					Rstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}

public void  checkUpRight(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		do
		{
			
			tempC--;
			tempR--;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart--;
					Rstart--;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}


public void  checkUp(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		
		do
		{
			
			tempC--;
			limit++;
		}
		while (the_buttons[rows][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[rows][Cstart].setIcon(temp);
					Cstart--;
					if(the_buttons[rows][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[rows][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}


	public void checkforColunm(int j,int i)
	{
	    
		   
		 if (i <8 && i > 1)
			 {
                  colunm = 1;
				  getRow(i,1);
			System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			 }
        else if (i <16 && i >9)
	        {
                   colunm = 2;
				  getRow(i,9);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
		    }
		 else if (i <24 && i >17)
			{
			       colunm = 3;
				   getRow(i,17);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i <40 && i >33)
			{
			       colunm = 5;
				   getRow(i,33);
					System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 32 && i > 25)
			{

			       colunm = 4;
				   getRow(i,25);
				 		System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		else if (i <48 && i > 41)
			{
			       colunm = 6;
		          getRow(i,41);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 57 && i > 49)
			{
			       colunm = 7;
				   getRow(i,49);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 64 && i > 58)
			{
			      colunm = 8;
				  getRow(i,5

You just forgot to mention that beside that you getting another 30 errors, not nice of you...

--------------------Configuration: <Default>--------------------
C:\Downloads\othello.java:692: illegal start of type
        else if (checkWhichPlayer()==false)
        ^
C:\Downloads\othello.java:692: ';' expected
        else if (checkWhichPlayer()==false)
            ^
C:\Downloads\othello.java:692: illegal start of type
        else if (checkWhichPlayer()==false)
                ^
C:\Downloads\othello.java:692: ';' expected
        else if (checkWhichPlayer()==false)
                                   ^
C:\Downloads\othello.java:731: illegal start of type
        return true;       
        ^
C:\Downloads\othello.java:731: ';' expected
        return true;       
              ^
C:\Downloads\othello.java:734: class, interface, or enum expected
public boolean checkForSq()
       ^
C:\Downloads\othello.java:742: class, interface, or enum expected
                    return false;
                    ^
C:\Downloads\othello.java:743: class, interface, or enum expected
                 }       
                 ^
C:\Downloads\othello.java:745: class, interface, or enum expected
       }
       ^
C:\Downloads\othello.java:747: class, interface, or enum expected
public void checkForWin() 
       ^
C:\Downloads\othello.java:750: class, interface, or enum expected
            for ( i=0 ;i < 64 ;i++ )
                       ^
C:\Downloads\othello.java:750: class, interface, or enum expected
            for ( i=0 ;i < 64 ;i++ )
                               ^
C:\Downloads\othello.java:755: class, interface, or enum expected
                }
                ^
C:\Downloads\othello.java:759: class, interface, or enum expected
                }
                ^
C:\Downloads\othello.java:763: class, interface, or enum expected
            if(redButtons < YellowButtons)
            ^
C:\Downloads\othello.java:766: class, interface, or enum expected
    }
    ^
C:\Downloads\othello.java:775: class, interface, or enum expected
                 if (i == 2 )
                 ^
C:\Downloads\othello.java:777: class, interface, or enum expected
                 if (i == 3 )
                 ^
C:\Downloads\othello.java:779: class, interface, or enum expected
                 if (i == 4 )
                 ^
C:\Downloads\othello.java:781: class, interface, or enum expected
                 if (i == 5 )
                 ^
C:\Downloads\othello.java:784: class, interface, or enum expected
    }
    ^
C:\Downloads\othello.java:788: class, interface, or enum expected
public static void main(String args[]) {
              ^
C:\Downloads\othello.java:790: class, interface, or enum expected
        frame.setSize(330,300);
        ^
C:\Downloads\othello.java:791: class, interface, or enum expected
        frame.setTitle("Othello");
        ^
C:\Downloads\othello.java:793: class, interface, or enum expected
        frame.setVisible(true);
        ^
C:\Downloads\othello.java:794: class, interface, or enum expected
        frame.addWindowListener(new WindowAdapter() {
        ^
C:\Downloads\othello.java:795: class, interface, or enum expected
            public void windowClosing(WindowEvent e) {
                   ^
C:\Downloads\othello.java:797: class, interface, or enum expected
            }
            ^
C:\Downloads\othello.java:799: class, interface, or enum expected
    }
    ^
30 errors

Process completed.

I'm very sorry about that this one has no errors I just complied it

Attachments
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import java.lang.*;




public class othello extends JFrame implements ActionListener
{

	   
		ImageIcon        temp,tempO;
		ImageIcon        BG,r,Y;
		GridLayout		 gl;
		BorderLayout	 bl;
		Panel			 info,Board,Blank,Blank2;
		TextField		 score[];
		Label			 label[];
		JButton		     the_buttons[][];
		JButton          start;
		String           red = "RED",yellow ="YELLOW",string;
        int				 i,j=1,n_buttons =8;
		int              rows,colunm,tempC =0,tempR=0;
		int              Rstart,Cstart;
		int				 player =1;
		int				 redButtons,YellowButtons,pressed=1;
        boolean          found = false;

public othello(){

		
		the_buttons = new JButton[9][9];
        info        = new Panel();
		Blank       = new Panel();
		Blank2      = new Panel();
		Board       = new Panel();
		score       = new TextField[2];
		label       = new Label[2];
		gl          = new GridLayout(8,8);
		bl          = new BorderLayout();
		BG          = new ImageIcon("Ablue.gif",""+i);
        r           = new ImageIcon("RedC.gif",""+i);
		Y           = new ImageIcon("YellowC.gif",""+i);
        start       = new JButton("start");
        score[0]	= new TextField(" " + redButtons);
		score[1]	= new TextField(" " + YellowButtons);
		label[0]	= new Label(red);
		label[1]	= new Label(yellow);
		
		setLayout(bl);
		Board.setLayout(gl);
		info.setLayout(gl);
		score[0].setEditable(false);
		score[1].setEditable(false);
		start.addActionListener(this);
	
		Blank.setBackground(Color.black);
		Blank2.setBackground(Color.black);
		
		 info.add(label[0]);
		 info.add(score[0]);
		 info.add(score[1]);
		 info.add(label[1]);
		 info.add(start);

		add("North",Blank2);
	    add("East",info);
		add("Center",Board);
		add("South",Blank);
		
		
	
	

		
		
        	
	
	for(i=1 ;i < 9; i++ )
		  {
		   
				the_buttons[1][i] = new JButton(""+j,BG); j++;
				the_buttons[2][i] = new JButton(""+j,BG); j++;
				the_buttons[3][i] = new JButton(""+j,BG); j++;
				the_buttons[4][i] = new JButton(""+j,BG); j++;
				the_buttons[5][i] = new JButton(""+j,BG); j++;
				the_buttons[6][i] = new JButton(""+j,BG); j++;
				the_buttons[7][i] = new JButton(""+j,BG); j++;
				the_buttons[8][i] = new JButton(""+j,BG); j++;
				
				the_buttons[1][i].addActionListener(this);
				the_buttons[2][i].addActionListener(this);
				the_buttons[3][i].addActionListener(this);
				the_buttons[4][i].addActionListener(this);
				the_buttons[5][i].addActionListener(this);
				the_buttons[6][i].addActionListener(this);
				the_buttons[7][i].addActionListener(this);
				the_buttons[8][i].addActionListener(this);
				Board.add(the_buttons[1][i]);
				Board.add(the_buttons[2][i]);
				Board.add(the_buttons[3][i]);
				Board.add(the_buttons[4][i]);
				Board.add(the_buttons[5][i]);
				Board.add(the_buttons[6][i]);
				Board.add(the_buttons[7][i]);
				Board.add(the_buttons[8][i]);
				
           }

		    
			the_buttons[5][4].setIcon(r);
			the_buttons[4][5].setIcon(r);
		        the_buttons[4][4].setIcon(Y);
	     	        the_buttons[5][5].setIcon(Y);
			
           
	
	}


	
public int countRed()
{
	for (i=0 ; i < 9 ;i++ )
	{
		
		if(the_buttons[i][i].getIcon().equals(r))
			redButtons ++;
		
	}System.out.println("Red Button: "+ redButtons);
	return redButtons;
}


public int countYellow()
{
	for (i=0 ; i < 9 ;i++ )
	{
		
		if(the_buttons[i][i].getIcon().equals(Y))
			YellowButtons ++;
				
	}System.out.println("Yellow Button: "+ YellowButtons);
	return YellowButtons;
}


public void actionPerformed(ActionEvent event){
		
		
		String cmd = event.getActionCommand(); //get the ActionCommand
		

		

				for (int i =1 ;i < 64 ;i++ )
				{
				   pressed++;
				
					if (cmd.equals(""+i))
						{
							 checkforColunm(j=0,i);
							 PickButton(rows,colunm);
                            
							// checkForWin();
                        }
				
			}
			
}


public void  checkForward(ImageIcon temp,ImageIcon tempO)
	{
		int limit=0;
		int Rstart = rows;
		     tempR = rows;

		do
		{
			tempR++;
			limit++;
		}
		while (the_buttons[tempR][colunm].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][colunm].setIcon(temp);
					Rstart++;
					if(the_buttons[tempR][colunm].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][colunm].getIcon().equals(BG)==true)
							  {break;}
				}				
							
			
	}


	public void  checkBackwards(ImageIcon temp,ImageIcon tempO)
	{
	    int limit=0;
		Rstart = rows;
		tempR = rows;

		do
		{
			tempR--;
			limit++;
		}
		while (the_buttons[tempR][colunm].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][colunm].setIcon(temp);
					Rstart--;
					if(the_buttons[tempR][colunm].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][colunm].getIcon().equals(BG)==true)
							  {break;}
				}				
					
	   	
	}


	public void  checkDownLeft(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Rstart = rows;
		 Cstart = colunm;
		 tempR = rows;
         tempC = colunm;
		
		do
		{
			tempR--;
			tempC++;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Rstart--;
					Cstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}				
					

	}


	public void  checkDownRight(ImageIcon temp,ImageIcon tempO)
	{
	 
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		do
		{
			tempR++;
			tempC++;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart++;
					Rstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}

	}


public void  checkDown(ImageIcon temp,ImageIcon tempO)
	{
	   		    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		
		do
		{
			
			tempC++;
			limit++;
		}
		while (the_buttons[rows][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[rows][Cstart].setIcon(temp);
					Cstart++;
					if(the_buttons[rows][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[rows][tempC].getIcon().equals(BG)==true)
							  {break;}
				}				
					

	}

public void  checkUpLeft(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		
		do
		{
			tempR++;
			tempC--;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart--;
					Rstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}

public void  checkUpRight(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		do
		{
			
			tempC--;
			tempR--;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart--;
					Rstart--;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}


public void  checkUp(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		
		do
		{
			
			tempC--;
			limit++;
		}
		while (the_buttons[rows][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[rows][Cstart].setIcon(temp);
					Cstart--;
					if(the_buttons[rows][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[rows][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}


	public void checkforColunm(int j,int i)
	{
	    
		   
		 if (i <8 && i > 1)
			 {
                  colunm = 1;
				  getRow(i,1);
			System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			 }
        else if (i <16 && i >9)
	        {
                   colunm = 2;
				  getRow(i,9);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
		    }
		 else if (i <24 && i >17)
			{
			       colunm = 3;
				   getRow(i,17);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i <40 && i >33)
			{
			       colunm = 5;
				   getRow(i,33);
					System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 32 && i > 25)
			{

			       colunm = 4;
				   getRow(i,25);
				 		System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		else if (i <48 && i > 41)
			{
			       colunm = 6;
		          getRow(i,41);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 57 && i > 49)
			{
			       colunm = 7;
				   getRow(i,49);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 64 && i > 58)
			{
			      colu

no I'm trying to fix that too It's late and I just cant think.Any suggestions on either problems?

take this file, i added this line to help you,
System.out.println("This"+rows+" "+colunm); line number 730

look at the printed values, you are exceeding 9.

Attachments
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import java.lang.*;




public class othello extends JFrame implements ActionListener
{

	   
		ImageIcon        temp,tempO;
		ImageIcon        BG,r,Y;
		GridLayout		 gl;
		BorderLayout	 bl;
		Panel			 info,Board,Blank,Blank2;
		TextField		 score[];
		Label			 label[];
		JButton		     the_buttons[][];
		JButton          start;
		String           red = "RED",yellow ="YELLOW",string;
        int				 i,j=1,n_buttons =8;
		int              rows,colunm,tempC =0,tempR=0;
		int              Rstart,Cstart;
		int				 player =1;
		int				 redButtons,YellowButtons,pressed=1;
        boolean          found = false;

public othello(){

		
		the_buttons = new JButton[9][9];
        info        = new Panel();
		Blank       = new Panel();
		Blank2      = new Panel();
		Board       = new Panel();
		score       = new TextField[2];
		label       = new Label[2];
		gl          = new GridLayout(8,8);
		bl          = new BorderLayout();
		BG          = new ImageIcon("Ablue.gif",""+i);
        r           = new ImageIcon("RedC.gif",""+i);
		Y           = new ImageIcon("YellowC.gif",""+i);
        start       = new JButton("start");
        score[0]	= new TextField(" " + redButtons);
		score[1]	= new TextField(" " + YellowButtons);
		label[0]	= new Label(red);
		label[1]	= new Label(yellow);
		
		setLayout(bl);
		Board.setLayout(gl);
		info.setLayout(gl);
		score[0].setEditable(false);
		score[1].setEditable(false);
		start.addActionListener(this);
	
		Blank.setBackground(Color.black);
		Blank2.setBackground(Color.black);
		
		 info.add(label[0]);
		 info.add(score[0]);
		 info.add(score[1]);
		 info.add(label[1]);
		 info.add(start);

		add("North",Blank2);
	    add("East",info);
		add("Center",Board);
		add("South",Blank);
		
		
	
	

		
		
        	
	
	for(i=1 ;i < 9; i++ )
		  {
		   
				the_buttons[1][i] = new JButton(""+j,BG); j++;
				the_buttons[2][i] = new JButton(""+j,BG); j++;
				the_buttons[3][i] = new JButton(""+j,BG); j++;
				the_buttons[4][i] = new JButton(""+j,BG); j++;
				the_buttons[5][i] = new JButton(""+j,BG); j++;
				the_buttons[6][i] = new JButton(""+j,BG); j++;
				the_buttons[7][i] = new JButton(""+j,BG); j++;
				the_buttons[8][i] = new JButton(""+j,BG); j++;
				
				the_buttons[1][i].addActionListener(this);
				the_buttons[2][i].addActionListener(this);
				the_buttons[3][i].addActionListener(this);
				the_buttons[4][i].addActionListener(this);
				the_buttons[5][i].addActionListener(this);
				the_buttons[6][i].addActionListener(this);
				the_buttons[7][i].addActionListener(this);
				the_buttons[8][i].addActionListener(this);
				Board.add(the_buttons[1][i]);
				Board.add(the_buttons[2][i]);
				Board.add(the_buttons[3][i]);
				Board.add(the_buttons[4][i]);
				Board.add(the_buttons[5][i]);
				Board.add(the_buttons[6][i]);
				Board.add(the_buttons[7][i]);
				Board.add(the_buttons[8][i]);
				
           }

		    
			the_buttons[5][4].setIcon(r);
			the_buttons[4][5].setIcon(r);
		        the_buttons[4][4].setIcon(Y);
	     	        the_buttons[5][5].setIcon(Y);
			
           
	
	}


	
public int countRed()
{
	for (i=0 ; i < 9 ;i++ )
	{
		
		if(the_buttons[i][i].getIcon().equals(r))
			redButtons ++;
		
	}System.out.println("Red Button: "+ redButtons);
	return redButtons;
}


public int countYellow()
{
	for (i=0 ; i < 9 ;i++ )
	{
		
		if(the_buttons[i][i].getIcon().equals(Y))
			YellowButtons ++;
				
	}System.out.println("Yellow Button: "+ YellowButtons);
	return YellowButtons;
}


public void actionPerformed(ActionEvent event){
		
		
		String cmd = event.getActionCommand(); //get the ActionCommand
		

		

				for (int i =1 ;i < 64 ;i++ )
				{
				   pressed++;
				
					if (cmd.equals(""+i))
						{
							 checkforColunm(j=0,i);
							 PickButton(rows,colunm);
                            
							// checkForWin();
                        }
				
			}
			
}


public void  checkForward(ImageIcon temp,ImageIcon tempO)
	{
		int limit=0;
		int Rstart = rows;
		     tempR = rows;

		do
		{
			tempR++;
			limit++;
		}
		while (the_buttons[tempR][colunm].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][colunm].setIcon(temp);
					Rstart++;
					if(the_buttons[tempR][colunm].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][colunm].getIcon().equals(BG)==true)
							  {break;}
				}				
							
			
	}


	public void  checkBackwards(ImageIcon temp,ImageIcon tempO)
	{
	    int limit=0;
		Rstart = rows;
		tempR = rows;

		do
		{
			tempR--;
			limit++;
		}
		while (the_buttons[tempR][colunm].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][colunm].setIcon(temp);
					Rstart--;
					if(the_buttons[tempR][colunm].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][colunm].getIcon().equals(BG)==true)
							  {break;}
				}				
					
	   	
	}


	public void  checkDownLeft(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Rstart = rows;
		 Cstart = colunm;
		 tempR = rows;
         tempC = colunm;
		
		do
		{
			tempR--;
			tempC++;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Rstart--;
					Cstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}				
					

	}


	public void  checkDownRight(ImageIcon temp,ImageIcon tempO)
	{
	 
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		do
		{
			tempR++;
			tempC++;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart++;
					Rstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}

	}


public void  checkDown(ImageIcon temp,ImageIcon tempO)
	{
	   		    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		
		do
		{
			
			tempC++;
			limit++;
		}
		while (the_buttons[rows][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[rows][Cstart].setIcon(temp);
					Cstart++;
					if(the_buttons[rows][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[rows][tempC].getIcon().equals(BG)==true)
							  {break;}
				}				
					

	}

public void  checkUpLeft(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		
		do
		{
			tempR++;
			tempC--;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart--;
					Rstart++;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}

public void  checkUpRight(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		 Rstart = rows;
		 tempR = rows;
		
		do
		{
			
			tempC--;
			tempR--;
			limit++;
		}
		while (the_buttons[tempR][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[Rstart][Cstart].setIcon(temp);
					Cstart--;
					Rstart--;
					if(the_buttons[tempR][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[tempR][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}


public void  checkUp(ImageIcon temp,ImageIcon tempO)
	{
	
		
				    	
		 int limit=0;
		 Cstart = colunm;
		 tempC = colunm;
		
		do
		{
			
			tempC--;
			limit++;
		}
		while (the_buttons[rows][tempC].getIcon().equals(tempO)==true || rows ==0);
			
			for (j=0; j < limit ; j++ )
				{
				    
					the_buttons[rows][Cstart].setIcon(temp);
					Cstart--;
					if(the_buttons[rows][tempC].getIcon().equals(tempO)==true)
							  {break;}
					if(the_buttons[rows][tempC].getIcon().equals(BG)==true)
							  {break;}
				}
			
	}


	public void checkforColunm(int j,int i)
	{
	    
		   
		 if (i <8 && i > 1)
			 {
                  colunm = 1;
				  getRow(i,1);
			System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			 }
        else if (i <16 && i >9)
	        {
                   colunm = 2;
				  getRow(i,9);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
		    }
		 else if (i <24 && i >17)
			{
			       colunm = 3;
				   getRow(i,17);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i <40 && i >33)
			{
			       colunm = 5;
				   getRow(i,33);
					System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 32 && i > 25)
			{

			       colunm = 4;
				   getRow(i,25);
				 		System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		else if (i <48 && i > 41)
			{
			       colunm = 6;
		          getRow(i,41);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 57 && i > 49)
			{
			       colunm = 7;
				   getRow(i,49);
						System.out.println("I = " + i +" Row: "+rows+ " Colunm: "+colunm);
			}
		 else if (i < 64 && i > 58)
			{
			      colu

I know in the_buttons[2][8],[3][8],[4][8] the lines also says that the rows are -1 so [4][8] say's it's [3][8]. but I cant find why this is happening the same with the exceeding the array I tried changing the array to [8][8] but it doesn't work. I know it's something small and right in front of me i just cant see it.

Ya that seemed to work for a few buttons I'll try go through the rest Cause I need this in early tomorrow.Any suggestions on the Null pointer?

This article has been dead for over six months. Start a new discussion instead.