Drawing with Java: Applying Borders/Outlines to Shapes
<p>I can't figure out how to get "g.setStroke(new BasicStroke(5));" to be set to all my created shapes (in this case ovals).</p>

<p>My code:</p>

<pre><code>import java.awt.*;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.BasicStroke;

public class Rings 
{
    public static void main(String[] args) 
    {
        DrawingPanel panel = new DrawingPanel(300, 300);

        Graphics2D g = panel.getGraphics();
        g.setStroke(new BasicStroke(5)); // Sets Outer Line Width of Shapes
        g.setColor(new Color(255, 0, 0));
        g.fillOval(50, 50, 200, 200); // Large Oval
        g.setColor(new Color(200, 0, 0));
        g.fillOval(100, 100, 100, 100); // Medium Oval
        g.setColor(new Color(150, 0, 0));
        g.fillOval(125, 125, 50, 50); // Small Oval
        g.setColor(new Color(100, 0, 0));
        g.fillOval(137, 137, 25, 25); // Tiny Oval
    }
}
</code></pre>

<p>My output:</p>

<p><a href="https://i.stack.imgur.com/p3ZN3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p3ZN3.png" alt="My Output"></a></p>

<p>Correct output:</p>

<p><a href="https://i.stack.imgur.com/j58c5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j58c5.png" alt="Correct output"></a></p>