This section illustrates you how to draw a dashed oval.
To give the stylistic and impressive representation of the outline, we have used the class BasicStroke. This class has been given by the interface Stroke. The class BasicStroke defines some methods to give the impressive way of showing the outline.
The BasicStroke.CAP_BUTT gives the dash segments. The BasicStroke.JOIN_BEVEL connects the outer corners of outlines with a straight segment. The class Ellipse2D is defined to provide the round figure which shows the outline.
The method setPaint(Color.gray) paints the outline with gray color. The method setStroke() sets the stroke settings for the Graphics2D context, when you draw the shape.
Here is the code of DrawDashedOval.java
Output will be displayed as:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial