Here you can find the source of drawDashedRect(Graphics g, int x, int y, int width, int height)
public static void drawDashedRect(Graphics g, int x, int y, int width, int height)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; public class Main { public static void drawDashedRect(Graphics g, int x, int y, int width, int height) { int vx, vy; // draw upper and lower horizontal dashes for (vx = x; vx < (x + width); vx += 2) { g.fillRect(vx, y, 1, 1);//from ww w .jav a 2 s .c o m g.fillRect(vx, y + height - 1, 1, 1); } // draw left and right vertical dashes for (vy = y; vy < (y + height); vy += 2) { g.fillRect(x, vy, 1, 1); g.fillRect(x + width - 1, vy, 1, 1); } } }