I'm tring to write a method the creates an empty rectangle inside which there is another white rectangle surrounded by a pattern of lines (contained in the for loop). 
Whenever the method is run I get a null point exception on first line of the loop. 
I can't work out what's going on... please help. 
   public void displayArea () {
            Graphics g = chartPanel.getGraphics();
            int Xpos = 30;
            int Ypos = 50;
            int displayWidth = 300;
            int displayHeight = 280;
            int borderPatternY = 10;
            int borderPatternX = 10; 
            for (int count = 0; borderPatternY <= 300 || borderPatternX <= 280; count++){
                g.drawLine(30, borderPatternY, 330, borderPatternY);
                g.drawLine(borderPatternX, 50, borderPatternX, 320);
                borderPatternX = borderPatternX + 10;
                borderPatternY = borderPatternY + 10;
            }
            g.setColor(Color.white);
            g.fillRect(Xpos + 10, Ypos + 10, displayWidth-10, displayHeight -10);
            g.setColor(Color.black);
            g.drawLine(Xpos, 60, Xpos + displayWidth, 60);
            g.drawLine(Xpos, 120, Xpos + displayWidth, 120);
            g.drawLine(Xpos, 180, Xpos + displayWidth, 180);
            g.drawLine(Xpos, 240, Xpos + displayWidth, 240);
        }
 
    