draw Dashed Line - Java 2D Graphics

Java examples for 2D Graphics:Line

Description

draw Dashed Line

Demo Code


//package com.java2s;
import java.awt.Graphics;

public class Main {
    public static void drawDashedLine(Graphics g, int x1, int y1, int x2,
            int y2) {
        for (int i = x1; i <= x2; i += 2) {
            for (int j = y1; j <= y2; j += 2) {
                g.fillRect(i, j, 1, 1);//from   w  w w .ja  va 2  s.  c om
            }
        }
    }
}

Related Tutorials