private void draw_grid(Graphics g)
    {
        Graphics2D g2d = (Graphics2D) g.create();

        int width = getWidth();

        int height = getHeight();

        int cellWidth = 20;
        int cellHeight = 20;

        int xOffset = (width - ((width / cellWidth) * cellWidth)) / 2;
        int yOffset = (height - ((height / cellHeight) * cellHeight)) / 2;
        //  if (cells.isEmpty())
        {
            for (int row = 0; row < (width / cellWidth); row++)
            {
                for (int col = 0; col < (height / cellHeight); col++)
                {
                    Rectangle cell = new Rectangle(
                            xOffset + (col * cellWidth),
                            yOffset + (row * cellHeight),
                            cellWidth,
                            cellHeight);
                    cells.add(cell);
                }
            }
        }

        g2d.setColor(Color.GRAY);
        for (Rectangle cell : cells)
        {
            g2d.draw(cell);
        }

        g2d.dispose();
    }