>>>>>>>>>>>>>>>>> import java.awt.*; /** An example of creating a custom dashed line for drawing. * ********************* public class DashedStrokeExample extends FontExample { public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D)g; drawGradientCircle(g2d); drawBigString(g2d); drawDashedCircleOutline(g2d); } protected void drawDashedCircleOutline(Graphics2D g2d) { g2d.setPaint(Color.blue); // 30-pixel line, 10-pixel gap, 10-pixel line, 10-pixel gap float[] dashPattern = { 30, 10, 10, 10 }; g2d.setStroke(new BasicStroke(8, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0)); g2d.draw(getCircle()); } public static void main(String[] args) { WindowUtilities.openInJFrame(new DashedStrokeExample(), 380, 400); } } <<<<<<<<<<<<<<
DashedStrokeExample.java Draws a circle with a dashed line segment (border). Inherits from FontExample.java.
Permanent link to this article: http://bangla.sitestree.com/dashedstrokeexample-java-draws-a-circle-with-a-dashed-line-segment-border-inherits-from-fontexample-java/