bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 4, Problem 17E

Explanation of Solution

Creating the class “MultipleCircles.java”:

  • Import required packages.
  • Define the class “MultipleCircles”.
    • Declare and define six constants.
    • Define the “main ()” method.
      • Launch the application.
    • Override the “start ()” method that throws “Exception”.
      • Create a group, scene, canvas and graphics context.
      • Declare required variables.
      • Loop from 0 through total number of circles using “for” loop.
        • Draw a circle and change the center position and diameter.
          • Add the canvas.
          • Set the title.
          • Add scene to the state and display it using “show ()” method.

Program:

//Import required packages

import javafx.application.Application;

import javafx.scene.canvas.Canvas;

import javafx.scene.Scene;

import javafx.scene.Group;

import javafx.stage.Stage;

import javafx.scene.canvas.GraphicsContext;

//Define the main class than extends application class

public class MultipleCircles extends Application

{

    //Six constants

    //Declare required constant variables

    //Set the number of circles

    public static final int CIRCLES = 10;

    //Set the number of diameter

    public static final int DIAMETER = 50;

    //Set x and y coordinates

    public static final int X_CIRCLE = 25;

    public static final int Y_CIRCLE = 100;

    //Set distance between adjacent centers

    public static final int CENTER_CHANGE = 20;

    //Set change in diameter

    public static final int DIAMETER_CHANGE = 10;

    //Define the main method

     public static void main(String[] args)

     {

         //Launch the application

        launch(args);

     }

     //Override the start method

     @Override

public void start(Stage primaryStage) throws Exception

     {

         //Create a group

        Group g = new Group();

        //Create a scene

        Scene s = new Scene(g);

        //Create canvas

        Canvas c = new Canvas(400, 400);

        //Create an object for graphics context

        GraphicsContext gc = c...

Blurred answer
Students have asked these similar questions
Need Java method please. Thank you.
Need Java method please. Thank you.
3. Write two nested loops to generate the following output. (Note: There is one space between each number, and any extra line shown is intentional.) 12 10 8 6 18 15 12 24 20 30 2 3 3 6 48 12 5 10 15 20 6 12 18 24 30

Chapter 4 Solutions

Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
The maximum force (P).

INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)

The bearing of line FG.

Elementary Surveying: An Introduction To Geomatics (15th Edition)

(a) Definition of supertype

Modern Database Management

Import the required packages. Declare the class “Main”. Declare the “main ()” method. Declare required variable...

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

The rotation of workpiece between the centers of lathe.

Degarmo's Materials And Processes In Manufacturing

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY