Here you can find the source of drawCheckerPattern(Graphics g_, int checkerSize)
public static void drawCheckerPattern(Graphics g_, int checkerSize)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; public class Main { public static void drawCheckerPattern(Graphics g_, int checkerSize) { Graphics2D g = (Graphics2D) g_; g.setColor(new Color(150, 150, 200)); Rectangle clipBounds = g.getClipBounds(); g.fillRect(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height); g.setColor(Color.GRAY);// ww w . j a va 2s . co m for (int i = floor(clipBounds.x, checkerSize); i < clipBounds.width + clipBounds.x; i += checkerSize) for (int j = floor(clipBounds.y, checkerSize); j < clipBounds.height + clipBounds.y; j += checkerSize) if (((i + j) / checkerSize) % 2 == 0) g.fillRect(i, j, checkerSize, checkerSize); } private static int floor(int val, int base) { return val / base * base; } }