Here you can find the source of grid(BufferedImage image, int between)
public static void grid(BufferedImage image, int between)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; public class Main { public static void grid(BufferedImage image, int between) { Graphics g = image.getGraphics(); g.setColor(Color.gray.brighter()); for (int x = 0; x < image.getWidth(); x += between) { g.drawRect(x, 0, 0, image.getHeight()); }//from w ww . j a v a 2 s.c om for (int y = 0; y < image.getHeight(); y += between) { g.drawRect(0, y, image.getWidth(), 0); } } }