Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 12, Problem 6AW
Explanation of Solution
“Image” and “ImageView” classes:
- “Image” class is used to load graphical images which can be displayed with the help of “ImageView” class.
- The package used for the image class is “javafx.scene.image.Image” which help to load the image from the URL or filename.
- It is possible to set one image to many “ImageView” because, one image can be displayed in multiple views. Whereas, it is not possible to display one “ImageView” multiple times because an “ImageView” node cannot be shared.
- Syntax to create image: Image image_object = new Image(URL);
- Syntax to view image: ImageView imageview_object = new ImageView(image_object);
Step 1: Create an object for “Image” to load the image.
Step 2: Give the given URL “http://www.greendale.edu/images/” followed by the image name “Cat.png” as the argument to load image from the internet location.
Code to create “Image” object:
The code to create “Image” object to load “Cat...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
in javascript Create a function that will load a new image from the website https://cataas.com/cat every 10 seconds, and will stop this interval when the SPACEBAR is pressed.
comment this code:
import sysfrom PyQt5.QtCore import *from PyQt5.QtWidgets import *from PyQt5.QtWebEngineWidgets import *class MainWindow(QMainWindow):def __init__(self):super(MainWindow, self).__init__()self.browser = QWebEngineView()self.browser.setUrl(QUrl('http://google.com'))self.setCentralWidget(self.browser)self.showMaximized()# navbarnavbar = QToolBar()self.addToolBar(navbar)back_btn = QAction('Back', self)back_btn.triggered.connect(self.browser.back)navbar.addAction(back_btn)forward_btn = QAction('Forward', self)forward_btn.triggered.connect(self.browser.forward)navbar.addAction(forward_btn)reload_btn = QAction('Reload', self)reload_btn.triggered.connect(self.browser.reload)navbar.addAction(reload_btn)home_btn = QAction('Home', self)home_btn.triggered.connect(self.navigate_home)navbar.addAction(home_btn)self.url_bar = QLineEdit()self.url_bar.returnPressed.connect(self.navigate_to_url)navbar.addWidget(self.url_bar)self.browser.urlChanged.connect(self.update_url)def…
Comment this codei
import sysfrom PyQt5.QtCore import *from PyQt5.QtWidgets import *from PyQt5.QtWebEngineWidgets import *class MainWindow(QMainWindow):def __init__(self):super(MainWindow, self).__init__()self.browser = QWebEngineView()self.browser.setUrl(QUrl('http://google.com'))self.setCentralWidget(self.browser)self.showMaximized()# navbarnavbar = QToolBar()self.addToolBar(navbar)back_btn = QAction('Back', self)back_btn.triggered.connect(self.browser.back)navbar.addAction(back_btn)forward_btn = QAction('Forward', self)forward_btn.triggered.connect(self.browser.forward)navbar.addAction(forward_btn)reload_btn = QAction('Reload', self)reload_btn.triggered.connect(self.browser.reload)navbar.addAction(reload_btn)home_btn = QAction('Home', self)home_btn.triggered.connect(self.navigate_home)navbar.addAction(home_btn)self.url_bar = QLineEdit()self.url_bar.returnPressed.connect(self.navigate_to_url)navbar.addWidget(self.url_bar)self.browser.urlChanged.connect(self.update_url)def…
Chapter 12 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 12.1 - What is a user interface?Ch. 12.1 - How does a command line interface work?Ch. 12.1 - Prob. 12.3CPCh. 12.1 - Prob. 12.4CPCh. 12.2 - What is JavaFX?Ch. 12.2 - Prob. 12.6CPCh. 12.2 - Prob. 12.7CPCh. 12.2 - Prob. 12.8CPCh. 12.2 - Prob. 12.9CPCh. 12.2 - Prob. 12.10CP
Ch. 12.2 - Prob. 12.11CPCh. 12.2 - What is the purpose of the Application classs...Ch. 12.2 - Prob. 12.13CPCh. 12.2 - Prob. 12.14CPCh. 12.3 - Prob. 12.15CPCh. 12.3 - Prob. 12.16CPCh. 12.3 - Prob. 12.17CPCh. 12.3 - How do you change the alignment of an HBox...Ch. 12.3 - Prob. 12.19CPCh. 12.4 - Prob. 12.20CPCh. 12.4 - Prob. 12.21CPCh. 12.4 - Prob. 12.22CPCh. 12.4 - Prob. 12.23CPCh. 12.4 - Prob. 12.24CPCh. 12.5 - Prob. 12.25CPCh. 12.5 - Prob. 12.26CPCh. 12.5 - Prob. 12.27CPCh. 12.5 - Prob. 12.28CPCh. 12.6 - Prob. 12.29CPCh. 12.6 - Prob. 12.30CPCh. 12.6 - Prob. 12.31CPCh. 12.6 - Prob. 12.32CPCh. 12.7 - Prob. 12.33CPCh. 12.7 - Prob. 12.34CPCh. 12.8 - Prob. 12.35CPCh. 12.9 - Prob. 12.36CPCh. 12.9 - Prob. 12.37CPCh. 12 - Prob. 1MCCh. 12 - This type of control appears as a rectangular...Ch. 12 - Typically, when the user clicks this type of...Ch. 12 - Prob. 4MCCh. 12 - Prob. 5MCCh. 12 - Prob. 6MCCh. 12 - Prob. 7MCCh. 12 - All JavaFX applications must extend the class. a....Ch. 12 - This container arranges its contents in a single,...Ch. 12 - You use this class to load an image file into...Ch. 12 - You use this class to actually display an image....Ch. 12 - The EventHandler interface specifies a method...Ch. 12 - Prob. 13MCCh. 12 - Prob. 14MCCh. 12 - Prob. 15TFCh. 12 - Prob. 16TFCh. 12 - Prob. 17TFCh. 12 - Prob. 18TFCh. 12 - Prob. 1FTECh. 12 - Prob. 2FTECh. 12 - Assume hbox is an HBox container: // This code has...Ch. 12 - Prob. 4FTECh. 12 - Prob. 5FTECh. 12 - Prob. 1AWCh. 12 - Prob. 2AWCh. 12 - Prob. 3AWCh. 12 - Prob. 4AWCh. 12 - Prob. 5AWCh. 12 - Prob. 6AWCh. 12 - Prob. 7AWCh. 12 - Prob. 8AWCh. 12 - Prob. 9AWCh. 12 - Prob. 10AWCh. 12 - Assume a JavaFX application has a Button control...Ch. 12 - Prob. 12AWCh. 12 - Prob. 13AWCh. 12 - Assume borderPane is the name of an existing...Ch. 12 - Prob. 1SACh. 12 - What is the purpose of the Application classs...Ch. 12 - What is the purpose of the Application classs...Ch. 12 - What purpose do layout containers serve?Ch. 12 - Prob. 5SACh. 12 - What two classes do you use to display an image?Ch. 12 - Prob. 7SACh. 12 - Prob. 8SACh. 12 - Prob. 9SACh. 12 - Prob. 10SACh. 12 - Prob. 11SACh. 12 - Latin Translator Look at the following list of...Ch. 12 - Name Formatter Create a JavaFX application that...Ch. 12 - Tip, Tax, and Total Create a JavaFX application...Ch. 12 - Property Tax A county collects property taxes on...Ch. 12 - Prob. 5PCCh. 12 - Prob. 6PCCh. 12 - Travel Expenses Create a GUI application that...Ch. 12 - Joes Automotive Joes Automotive performs the...Ch. 12 - Tic-Tac-Toe Simulator Create a JavaFX application...Ch. 12 - Prob. 10PC
Knowledge Booster
Similar questions
- Comment these code importer sysfra PyQt5.QtCore import *fra import av PyQt5.QtWidgets *fra import av PyQt5.QtWebEngineWidgets *klasse MainWindow (QMainWindow):def __init __ (selv):super (MainWindow, selv) .__ init __ ()self.browser = QWebEngineView ()self.browser.setUrl (QUrl ('http://google.com'))self.setCentralWidget (self.browser)self.showMaximized ()navbar = QToolBar ()self.addToolBar (navbar)back_btn = QAction ('Tilbake', selv)back_btn.triggered.connect (self.browser.back)navbar.addAction (back_btn)forward_btn = QAction ('Fremover', selv)forward_btn.triggered.connect (self.browser.forward)navbar.addAction (forward_btn)reload_btn = QAction ('Reload', selv)reload_btn.triggered.connect (self.browser.reload)navbar.addAction (reload_btn)home_btn = QAction ('Hjem', selv)home_btn.triggered.connect (self.navigate_home)navbar.addAction (home_btn)self.url_bar = QLineEdit ()self.url_bar.returnPressed.connect (self.navigate_to_url)navbar.addWidget (self.url_bar)self.browser.urlChanged.connect…arrow_forwardMake the photo below into a grayscale using python. Let us assume that the photo below is located in a folder name 'pic' and the name of the photo is Bird.jpgCode for gray: def grayscale(image): for y in range(image.getHeight()): for x in range(image.getWidth()): (r, g, b) = image.getPixel(x, y) r = int(r * 0.299) g= int(g * 0.587) b = int(b * 0.114) lum = r + g + b image.setPixels(x, y, (lum, lum, lum))arrow_forwardCreate a login page and signup page and link them together using JAVAFX and FXML. Please show the code in order, print and image, and show the output in the answerarrow_forward
- JAVA code can only be added to the MessageDetails.java file. Between lines of get code (ie libnes 12 and 14, as seen on image).arrow_forwardin python Write a program that will open a file .csv, read its contents and print them out. Your output should look like this: .csv (look the image) the file looks like these image First Last Age Wagejane Smith 21.00 21.50Jack Jones 20.00 19.50Edgar Martinez 22.00 22.75Zanab Sayegh 21.00 21.75arrow_forwardDoes this display two images? And if so in which folder shall I add the gif files? package javafxapplication3; import javafx.application.Application;import javafx.scene.Scene;import javafx.scene.image.Image;import javafx.scene.image.ImageView;import javafx.scene.layout.GridPane;import javafx.stage.Stage; public class JavaFXApplication3 extends Application {@Overridepublic void start(Stage primaryStage)throws Exception {GridPane gridPane = new GridPane();int flagCount = 0;for (int i = 0; i<2; i++) {for (int j = 0; j<2; j++) { gridPane.add(new ImageView(new Image("image/flag"+flagCount+".gif")), i, j);flagCount++;}}Scene scene = new Scene(gridPane, 1000, 500);primaryStage.setTitle("Flags");primaryStage.setScene(scene);primaryStage.show();}public static void main(String[]args) {Application.launch(args);}}arrow_forward
- import image def draw_border(pic):'''Returns an image with a black border around it'''pass #You can leave this or remove it#Your code here to draw a black border around the image def main():'''Controls the program'''fname = "https://runestone.academy/runestone/books/published/StudentCSP/_static/swan.jpg"img = image.Image(fname)width = img.getWidth()height = img.getHeight()win = image.ImageWin(width, height)draw_border(img)img.draw(win) main() #Run the programarrow_forwardThis is a sample data in my JSON file: {"firstName": "Juan","middleName": "Dela","lastName": "Cruz","username": "Juan111","password": "1234"} Please make a JAVA GUI code that will display all the array lists (please make an iterator) in my JSON file. Please make it similar to the image. For each user, please add an "accept" and "reject" option. This will allow the server to decide whether or not to accept the client to the application. You do not have to code the acceptance of the client, just add the buttons, I will be the one to continue the code.arrow_forwardwrite a program that lets a user display and modify pictures, add 4 button so that clicking a particular button will shift the image by a small amount in the north,,south, east or west direction inside the windows. also a menu bar with 2 menus: File and Image, the file menu should contain an open menu item that users can select to display JPEC and PNG files from the disk in the windows. the Image menu should contain these menu items: Robert, Shear, and Scale when user selects any one of the items, an input dialog box should display, in which the users can specify the rotation anglearrow_forward
- In JavaFX: A stage with a Textfield and a button, this button opens a ListView with a contact list, the selected address must fill the TextField. The data shown in the ListView must be populated from a CSV file. Please post the code and the output screenshot.arrow_forwardCopy the text below in the text file "words.txt" The JavaFX Group component is a container component which applies no special layout to its children. All child components (nodes) are positioned at 0,0. A JavaFX Group component is typically used to apply some effect or transformation to a set of controls as a whole as a group. If you need some layout to the children inside the Group, nest them inside layout components and add the layout components to the Group. The JavaFX Group component is represented by the class javafx.scene.Group. Finish the implementatio of the methods public static ArrayList<String> read_words(String fname) public static int get_longest(ArrayList<String> data, int n) In the following code import java.util.*; import java.io.*; public class Words { public static void main(String[] args) { Scanner scan = new Scanner(System.in); ArrayList<String> data = read_words("words.txt") ; System.out.println("Size of the…arrow_forwardUsing comments within the code itself, can you provide an line by line explanation of the below JavaScript file? The file itself deals with WebGl if that helps you. Please and thank you JavaScript file: "use strict"; var canvas; var gl; var positions = []; var colors = []; var numTimesToSubdivide = 3; window.onload = function init() { canvas = document.getElementById("gl-canvas"); gl = canvas.getContext('webgl2'); if (!gl) alert("WebGL 2.0 isn't available"); // // Initialize our data for the Sierpinski Gasket // // First, initialize the vertices of our 3D gasket // Four vertices on unit circle // Intial tetrahedron with equal length sides var vertices = [ vec3(0.0000, 0.0000, -1.0000), vec3(0.0000, 0.9428, 0.3333), vec3(-0.8165, -0.4714, 0.3333), vec3(0.8165, -0.4714, 0.3333) ]; divideTetra(vertices[0], vertices[1], vertices[2], vertices[3], numTimesToSubdivide); // // Configure WebGL // gl.viewport(0, 0, canvas.width, canvas.height); gl.clearColor(1.0, 1.0, 1.0,…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT