Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 14, Problem 14.1PE
Program Plan Intro

Program Plan:

  • Import required packages.
  • Declare a main class named “ch14_1” which extends the “Application” class.
    • Declare a “start ()” method which overrides the “start ()” method in the “Application” class. Inside this method,
      • Create a GridPane in order to display images.
      • Place the pane in center position using “setAlignment ()” method.
      • Set the horizontal and vertical gap for the pane using “setHgap ()” and “setVgap ()” functions respectively.
      • Create four ImageView objects to display all the images from the file.
      • Add all the four images on their respective position on the pane.
      • Create a scene and place it on the stage.
      • Set the title as “Exercise14_01”.
      • Display the stage on the window using “primaryStage.show()” method.
    • Declare a main method using “public static main”.
      • Launch the method using “launch ()” method.

Expert Solution & Answer
Check Mark
Program Description Answer

The below program displays four images on the GridPane as per the given image.

Explanation of Solution

Program:

//Import required packages

import javafx.application.Application;

import javafx.geometry.Pos;

import javafx.scene.Scene;

import javafx.scene.layout.GridPane;

import javafx.stage.Stage;

import javafx.scene.image.ImageView;

//Main class extends Application

public class ch14_1 extends Application

{

//Overrides the start method in the application

@Override

//start method

public void start(Stage primaryStage)

{

//Create a GridPane to display images

GridPane GP = new GridPane();

//Place the pane in center position

GP.setAlignment(Pos.CENTER);

/*set the horizontal and vertical gap for the pane*/

GP.setHgap(5);

GP.setVgap(5);

/*Create 4 image views to display 4 images and pass the url from the file name*/

ImageView IV1 = new ImageView("snaps/germany.gif");

ImageView IV2 = new ImageView("snaps/china.gif");

ImageView IV3 = new ImageView("snaps/fr.gif");

ImageView IV4 = new ImageView("snaps/us.gif");

/*Add image to the pane in the first row, first column*/

GP.add(IV1, 0, 0);

/*Add image to the pane in the second row, first column*/

GP.add(IV2, 1, 0);

/*Add image to the pane in the first row, second column*/

GP.add(IV3, 0, 1);

/*Add image to the pane in the second row, second column*/

GP.add(IV4, 1, 1);

//Create a scene and place it on the stage

Scene scene = new Scene(GP);

//Setting title

primaryStage.setTitle("Exercise14_01");

//Place the scene on the stage

primaryStage.setScene(scene);

//Display the stage on the window

primaryStage.show();

}

//Main method

public static void main(String[] args)

{

//Launch the application

launch(args);

}

}

Sample Output

Screenshot of the output

Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition), Chapter 14, Problem 14.1PE

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
2. Identify and correct the errors in each of the following statements: a) if ( c !< 17 ); window.alert( "c is not less than 17" ); b) if ( c =< 17 ) window.alert( "c is equal to or less than 17" ); c) while ( c <= 5 ) { product *= c; ++c; d) if ( gender == 1 ) document.writeln( "Woman" ); else; document.writeln( "Man" ); e)var a = new Array( 20); for ( varj = 0; j = 30, ++i ){ a[ j ] = 0; }
3. Write C++ statements to define and initialize the following arrays. a. Array heights of 10 components of type double. Initialize this array to the following values: 5.2, 6.3, 5.8, 4.9, 5.2, 5.7, 6.7, 7.1, 5.10, 6.0. b. Array weights of 7 components of type int. Initialize this array to the following values: 120, 125, 137, 140, 150, 180, 210. c. Array specialSymbols of type char. Initialize this array to the following values: '$', '#', '%', '@', '&', '!', '^'. d. Array seasons of 4 components of type string. Initialize this array to the following values: "fall", "winter", "spring", "summer".
[2/25, 05:28] Vishal Singh Rawat: Kindly store employee details using class with python program [2/25, 05:28] Vishal Singh Rawat: There are 4 employees Details of all employee: Name: John , Designation: Manager , Salary: 80000 Name: Mike , Designation: Team Leader , Salary: 50000 Name: Derek , Designation: Programmer , Salary: 30000 Designation: Assistant , Salary: 25000 Name: Raj

Chapter 14 Solutions

Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)

Ch. 14.5 - Can you create an object of IntegerProperty using...Ch. 14.5 - Prob. 14.5.4CPCh. 14.6 - Prob. 14.6.1CPCh. 14.6 - Prob. 14.6.2CPCh. 14.7 - How do you create a color? What is wrong about...Ch. 14.7 - Prob. 14.7.2CPCh. 14.7 - Prob. 14.7.3CPCh. 14.8 - Prob. 14.8.1CPCh. 14.8 - Prob. 14.8.2CPCh. 14.9 - Prob. 14.9.1CPCh. 14.9 - Prob. 14.9.2CPCh. 14.9 - Prob. 14.9.3CPCh. 14.10 - Prob. 14.10.1CPCh. 14.10 - Prob. 14.10.2CPCh. 14.10 - Prob. 14.10.3CPCh. 14.10 - Prob. 14.10.4CPCh. 14.10 - Prob. 14.10.5CPCh. 14.11 - How do you display a text, line, rectangle,...Ch. 14.11 - Prob. 14.11.2CPCh. 14.11 - Prob. 14.11.3CPCh. 14.11 - Write code fragments to fill red color in a...Ch. 14.11 - Prob. 14.11.5CPCh. 14.11 - Prob. 14.11.6CPCh. 14.11 - Write code fragments to display the outline of the...Ch. 14.11 - Write code fragments to display the lower half of...Ch. 14.11 - Write code fragments to display a polygon...Ch. 14.11 - Write code fragments to display a polygon...Ch. 14.11 - Prob. 14.11.11CPCh. 14.12 - Prob. 14.12.1CPCh. 14 - Prob. 14.1PECh. 14 - Prob. 14.2PECh. 14 - (Display three cards) Write a program that...Ch. 14 - (Color and font) Write a program that displays...Ch. 14 - (Characters around circle) Write a program that...Ch. 14 - Prob. 14.6PECh. 14 - (Display random 0 or 1) Write a program that...Ch. 14 - (Create four fans) Write a program that places...Ch. 14 - (Display a cylinder) Write a program that draws a...Ch. 14 - Prob. 14.11PECh. 14 - (Display a bar chart) Write a program that uses a...Ch. 14 - Prob. 14.13PECh. 14 - (Display a rectanguloid) Write a program that...Ch. 14 - Prob. 14.15PECh. 14 - Prob. 14.16PECh. 14 - (Game: hangman) Write a program that displays a...Ch. 14 - Prob. 14.18PECh. 14 - (Plot the sine and cosine functions) Write a...Ch. 14 - (Draw an arrow line) Write a static method that...Ch. 14 - Prob. 14.21PECh. 14 - (Connect two circles) Write a program that draws...Ch. 14 - (Geometry: two rectangles) Write a program that...Ch. 14 - (Geometry: Inside a polygon?) Write a program that...Ch. 14 - Prob. 14.25PECh. 14 - Prob. 14.27PECh. 14 - (Random time) Modify the ClockPane class with...Ch. 14 - (Game: bean machine) Write a program that displays...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE 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