I need help! Java exception error

Hi everyone!
I am currently working on a JAVA project and i have a problem. I have tried to run a file and got this error message
exception in thread "main" java.lang.OutOfMemoryError:Java
i think i have done everything right, i have gone through the code again and again, edited where possible, but still i get the same error.
I have spent quite a lot of time in this and the deadline for the project submission is just around the corner. I believe there are Java gurus in here and i can find assistance.
Here is my code
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class board implements ActionListener{
JButton y[]=new JButton[1000000];
int xa, ya, i, l;
JFrame Dave;
public static void main(String[] args){
board chuy = new board();
chuy.setFrame();
}
public void setFrame(){
xa=0;
ya=0;
l=0;
i=1;
Dave = new JFrame("Board");
Dave.setLayout(new GraphPaperLayout(new Dimension(1000,1000)));
while(l<9999){
y[i]=new JButton("");
Dave.add(y[i], new Rectangle(xa,ya,1,1));
if(xa<=1000){
if(xa==1000){
xa=0;
ya++;
}
else xa++;
}
}
i++;
Dave.setVisible(true);
Dave.setSize(360,400);
Dave.setLocation(100,100);
Dave.setResizable(false);
Dave.setDefaultCloseOperation(Dave.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
}
On which section or line do you think the error could be and how do i fix it? I will greatly appreciate any help / suggestion or idea. Thanks in advance.
Nick.
