Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help returning the olympic rings. I did some of the code but I haven't had any luck returning a single ring. Instructions: Write

I need help returning the olympic rings. I did some of the code but I haven't had any luck returning a single ring.

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.

Code I did:

import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.Color;

public class Olympic { private int x; private int y; private int lineWidth; public Olympic(int x, int y, int lineWidth){ this.x=x; this.y=y; this.lineWidth = lineWidth; } public void draw(Graphics2D g2) { Ellipse2D.Double ring = new Ellipse2D.Double(x , y ,lineWidth, lineWidth); g2.setColor(Color.YELLOW); } }

import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent;

public class OlympicComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; Olympic ring1 = new Olympic(1, 0, 40);

ring1.draw(g2); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Google Analytics 4 The Data Driven Marketing Revolution

Authors: Galen Poll

2024th Edition

B0CRK92F5F, 979-8873956234

More Books

Students also viewed these Databases questions

Question

(4) C (U + 2102), the set of complex numbers; and Pg45

Answered: 1 week ago

Question

outline some of the current issues facing HR managers

Answered: 1 week ago