Changing the Thickness of the Stroking Pen

dashPhase is the offset to start the dashing pattern.
// See The Quintessential Drawing Program public void paint(Graphics g) { Graphics2D g2d = (Graphics2D)g; float strokeThickness = 5.0f; // A solid stroke BasicStroke stroke = new BasicStroke(strokeThickness); g2d.setStroke(stroke); // Draw shapes...; see Drawing Simple Shapes // A dashed stroke float miterLimit = 10f; float[] dashPattern = {10f}; float dashPhase = 5f; stroke = new BasicStroke(strokeThickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, miterLimit, dashPattern, dashPhase); g2d.setStroke(stroke); // Draw shapes...; see Drawing Simple Shapes }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.