Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming For this problem we are going to draw a rainbow Getting Set Up You will need some of the graphics classes in your

Java Programming

image text in transcribed

image text in transcribed

For this problem we are going to draw a "rainbow" Getting Set Up You will need some of the graphics classes in your project. Be sure to use the 2D graphics package as explained in your text. You will need to import the necessary classes into your project. Project specification Complete the RainbowComponent class. The application will draw rainbow will starting at (0,0) The colors will be displayed in rectangles rather than arcs. Each rectangle has a width of 100 and a height of 20. There are 7 rectangles. The colors of the first 5 should be made with the pre defined colors in the Color class. Use red, orange, yellow, green, and blue in that order. The next color is indigo and has RGB values (75, 0, 130). The last rectangle is violet with RGB values of (143, 0, 255). You will need to construct Color objects using these values This is what the result will look like: MyRaninbow Use the following file: RainbowViewer.iava import javax.swing.* public class RainbowViewer public static void main(Stringl args) JFrame frame = new JFrame() frame.setSize(300, 400); frame.setTitle(My Rainbow"); frame.setDefaultCloseOperation(JFrame.EXIT ON CLOSE); RainbowComponent componentnew RainbowComponent0 frame.add(component) frame.setVisible(true) RainbowComponent.java 1 import java.awt.color; 2 import java.awt.Graphics; 3 import java.awt.Graphics2D; 4 import java.awt.Rectangle; import javax.swing. JCompone nt; 8 public class RainbowComponent extends JComponent 10 private static final long serialVersionUID1L; 12 13 14 15 16 17 18 19 20 21 public void paintComponent (Graphics g) // Recover Graphics2D Graphics2D g2-(Graphics2D) g

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_2

Step: 3

blur-text-image_3

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt AI 4 3 0 .

Answered: 1 week ago