Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 15.10, Problem 15.10.1CP

Explanation of Solution

Purpose of the given code:

The purpose of the given code is resizing objects placed inside based on the window size. In the given code a rectangle and circle is placed inside the stack pane, the object gets resized based on the window size.

Given code:

//import the required packages

import javafx.application.Application ;

import javafx.scene.paint.Color ;

import javafx.scene.shape .Circle ;

import javafx.scene.shape.Rectangle ;

import javafx .stage.Stage;

import javafx.scene.Scene;

import javafx .scene.control .Label ;

import javafx.scene.layout.StackPane ;

//define the method ResizableCircleRectangle

public class ResizableCircleRectangle extends Application

{

//Create a circle

private Circle circle= new Circle( 60) ;

//new rectangle gets created

private Rectangle rectangle = new Rectangle( 120 , 120);

// Place clock and label in border pane

private StackPane pane = new StackPane() ;

@Override

// Override the start method in the Application class

public void start(Stage primaryStage)

{

//set the fill color of circle

circle.setFill (Color.GRAY) ;

//set the fill color of rectangle

rectangle.setFill (Color.WHITE);

//set the stroke color

rectangle.setStroke(Color.BLACK);

//add all to the pane

pane.getChildren() .addAll (rectangle, circle);

//new scene gets created and placed on the stage

Scene scene = new Scene (pane , 140, 140) ;

//set the title of the stage

primaryStage.setTitle( "ResizableCircleRectangle" );

//the scene gets placed on the stage

primaryStage .setScene(scene);

//the stage gets displayed

primaryStage.show();

//set the height property

pane.widthProperty().addListener(ov ->resize()) ;

//set the width property

pane.heightProperty() .addListener(ov -> resize());

}

//define the method resize

private void resize()

{

//define length of the pane

double length= Math...

Blurred answer
Students have asked these similar questions
i want the screenshot of the output also
Why do we talk about the output's visual quality being reduced when rasterizing?
I would like for the code in the attached image turned into a flow chart. Thanks in advance!

Chapter 15 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Ch. 15.6 - Prob. 15.6.1CPCh. 15.6 - What is a functional interface? Why is a...Ch. 15.6 - Prob. 15.6.3CPCh. 15.8 - Prob. 15.8.1CPCh. 15.8 - Prob. 15.8.2CPCh. 15.9 - Prob. 15.9.1CPCh. 15.9 - Prob. 15.9.2CPCh. 15.9 - Prob. 15.9.3CPCh. 15.9 - If the following code is inserted in line 57 in...Ch. 15.10 - Prob. 15.10.1CPCh. 15.11 - Prob. 15.11.1CPCh. 15.11 - Prob. 15.11.2CPCh. 15.11 - Prob. 15.11.3CPCh. 15.11 - Prob. 15.11.4CPCh. 15.12 - How does the program make the ball appear to be...Ch. 15.12 - How does the code in Listing 15.17, BallPane.java,...Ch. 15.12 - What does the program do when the mouse is pressed...Ch. 15.12 - If line 32 in Listing 15.18, BounceBall.java, is...Ch. 15.12 - Prob. 15.12.5CPCh. 15.13 - Prob. 15.13.1CPCh. 15.13 - What would happen if map is replaced by scene in...Ch. 15.13 - Prob. 15.13.3CPCh. 15 - Prob. 15.1PECh. 15 - (Rotate a rectangle) Write a program that rotates...Ch. 15 - (Move the ball) Write a program that moves the...Ch. 15 - (Create a simple calculator) Write a program to...Ch. 15 - (Create an investment-value calculator) Write a...Ch. 15 - (Alternate two messages) Write a program to...Ch. 15 - (Change color using a mouse) Write a program that...Ch. 15 - (Display the mouse position) Write two programs,...Ch. 15 - (Draw lines using the arrow keys) Write a program...Ch. 15 - (Enter and display a string) Write a program that...Ch. 15 - (Move a circle using keys) Write a program that...Ch. 15 - Prob. 15.12PECh. 15 - (Geometry: inside a rectangle?) Write a program...Ch. 15 - Prob. 15.14PECh. 15 - Prob. 15.15PECh. 15 - (Two movable vertices and their distances) Write a...Ch. 15 - (Geometry: find the bounding rectangle) Write a...Ch. 15 - Prob. 15.18PECh. 15 - (Game: eyehand coordination) Write a program that...Ch. 15 - Prob. 15.20PECh. 15 - (Drag points) Draw a circle with three random...Ch. 15 - (Auto resize cylinder) Rewrite Programming...Ch. 15 - Prob. 15.23PECh. 15 - Prob. 15.24PECh. 15 - Prob. 15.25PECh. 15 - Prob. 15.26PECh. 15 - Prob. 15.27PECh. 15 - (Display a running fan) Write a program that...Ch. 15 - (Racing car) Write a program that simulates car...Ch. 15 - Prob. 15.30PECh. 15 - Prob. 15.31PECh. 15 - (Control a clock) Modify Listing 14.21,...Ch. 15 - (Game: bean-machine animation) Write a program...Ch. 15 - Prob. 15.34PECh. 15 - Prob. 15.35PECh. 15 - Prob. 15.36PE
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education