'Swing library creating unwanted grid when trying to use for loops to run function on every pixel

A program I am writing, upon running, generates a mandelbrot set mostly correct, however it additionally generates a grid of blank space. I have not found a solution that does not sacrifice image quality.

Two nested loops is used to loop through every pixel on the JPanel, and run functionParser.Parse(...) recursively to calculate whether a given pixel is a part of the Mandelbrot set. Since the grid is generated without respect to the size of the window while the set is generated, I do not believe there is a problem with the parser, rather that there is either a problem with the Graphics class or with the loop.

A simplified example is below, which is intended to fill the window black, but exhibits the same grid behavior.

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

import Fractal.FractalPanel.DrawPane;

public class Dysfunctional extends JFrame{
    private static final long serialVersionUID = 1L;
    int r;
    JFrame frame;
    DrawPane d;
    public Dysfunctional() {
        setSize(200,200);
        this.setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        d=new DrawPane();
        setContentPane(d);
    }
    class DrawPane extends JPanel{
        int dimenX;
        int dimenY;
        public DrawPane() {
            this.setVisible(true);
            System.out.println("Pane generated");
            Dimension dim = getSize();
            dimenX=(int)dim.getWidth();
            dimenY=(int)dim.getHeight();
            System.out.println("Painting...");
        }
        public void paintComponent(Graphics g) {
            System.out.println("Generating...");
            Dimension dim = getSize();
            dimenX=(int)dim.getWidth();
            dimenY=(int)dim.getHeight();
            for(int xVal=0;xVal<dimenX;xVal++) {
                for(int yVal=0;yVal<dimenY;yVal++) {
                    if(true) {
                        g.drawRect(xVal,yVal,0,0);
                        //System.out.println("drawing");
                    }
                }
            }
            System.out.println("Done!");
            
        }
    }
    public static void main(String[] args) {
        new Dysfunctional();
    }
}

Output of contracted code, with unintended grid

Output of full code, Mandelbrot set with grid



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source