Question: I need help returning the rings from the Olympics logo. I got an error when I tried to return one ring. This code is in

I need help returning the rings from the Olympics logo. I got an error when I tried to return one ring. This code is in Java and I did some of it which I included down below.

These are the instructions:

Write a program that displays the Olympic rings logo. Color the rings in the Olympic colors. Provide classes OlympicRing, OlympicRingViewer and OlympicRingComponent.

To set the lineWidth for the rings, you can use: int lineWidth=4; g2.setStroke(new BasicStroke(lineWidth));

It is not necessary to interlock the rings as above. If you wish to try it as an embellishment, see java.awt.geom.Arc2D.Double.

my code:

import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.Color; import javax.swing.JComponent; import javax.swing.JFrame;

public class Olympic { private int xLeft; private int yTop; private int lineWidth; public Olympic(int x,int y, int lineWidth){ xLeft =x; yTop=y; lineWidth=4; } public void draw(Graphics2D g2){ g2.setStroke(new BasicStroke(lineWidth)); Ellipse2D.Double ring = new Ellipse2D.Double(xLeft,yTop,lineWidth, lineWidth); } } class OlympicRingViewer{ public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 230); frame.setTitle("Olympic Rings"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

OlympicRingComponent component = new OlympicRingComponent(); frame.add(component); frame.setVisible(true); } }

class OlympicRingComponent extends JComponent{ public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; Olympic ring1 = new Olympic(1,0,4); g2.setColor(Color.yellow); ring1.draw(g2); }

}

Transcribed image text

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!