how do i draw a dotted line around a circular jbutton?

You can use a BasicStroke to draw the oval.

Something like:

Graphics2D g2d = (Graphics2D)g.create();
g2d.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 5 }, 0));
g2d.setColor(...);
g.drawOval(getWidth() / 2 - diameter / 2, getHeight() / 2 - diameter / 2, diameter, diameter);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top