Question: Using Java JCreator: Edit and correct the code below to have the program to enter number of circles, each ring must be different color. The

Using Java JCreator: Edit and correct the code below to have the program to enter number of circles, each ring must be different color. The program must also check if there is a same color. The colors must be different to the human eye not based off their number value.

import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class Unit5Activity1 extends JPanel{ public void paintComponent(Graphics g){ super.paintComponent(g); Color color1 = new Color(100, 199, 100); Color color2 = new Color(208, 180, 45); for(int i = 5; i > 0; i--){ if(i == 1 || i == 3 || i == 5) { g.setColor(color1); g.fillOval(250 + i*25, 250 + i*25, 250 - 50*i, 250 - 50*i); } else if(i == 2 || i == 4){ g.setColor(color2); g.fillOval(250 + i*25, 250 + i*25, 250 - 50*i, 250 - 50*i); } } } public static void main(String[] args){ Unit5Activity1 panel = new Unit5Activity1(); JFrame application = new JFrame(); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); application.add(panel); application.setSize(500, 500); application.setVisible(true); }//main }//class

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!