Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Java. How can I fix my code so that it can fit these requirements: n is an integer that will be entered by a

For Java. How can I fix my code so that it can fit these requirements:

n is an integer that will be entered by a user in a JTextField

Add a JLabel prompt so the user will know what to enter in the text field

You must use the BorderLayout for the content pane in this application.

You can use the library method drawOval to draw an individual planet or create a more

advanced shape (i.e., using Polygon class).

Planets should be painted in random colors.

Use ActionEvent (button or text field) or MouseEvent to trigger drawing the planets.

my code:

import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; import java.util.Random; public class Random1 extends Applet { public void paint (Graphics page) { int NumOfCircles = 100; int diameter; int x, y; setBackground(Color.black); Random generator = new Random(); for (int count = 0; count < NumOfCircles; count++) { diameter = generator.nextInt(60); x = generator.nextInt(300); y = generator.nextInt(500);

page.setColor(new Color(generator.nextInt(256), generator.nextInt(256), generator.nextInt(256))); page.fillOval(x, y, diameter, diameter); } }}

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago