Starting Out with Java: Early Objects (6th Edition)
6th Edition
ISBN: 9780134462011
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 11, Problem 5AW
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);
Code to create “Image” and “ImageView” objects:
The code to create “Image” and “ImageView” objects to display “Cat.png” image is as follows:
//Creation of "Image" object
Image image_Object = new Image ("file:Cat...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
javafx programming show code and output in java eclipse ide
do not provide wrong answer please
Create animation in Figure tomeet the following requirements:■■ Allow the user to specify the animation speed in a text field.■■ Get the number of images and image’s file-name prefix from the user. Forexample, if the user enters n for the number of images and L for the imageprefix, then the files are L1.gif, L2.gif, and so on, to Ln.gif. Assume theimages are stored in the image directory, a subdirectory of the program’s classdirectory. The animation displays the images one after the other.■■ Allow the user to specify an audio file URL. The audio is played while theanimation runs.
10. Tic-Tac-Toe SimulatorCreate a JavaFX application that simulates a game of tic-tac-toe. Figure 15-55 shows anexample of the application’s GUI. The window shown in the figure uses nine ImageViewcomponents to display the Xs and Os. (You will find images for the X and the O in thebook’s Student Sample Files.)The application should use a two-dimensional int array to simulate the game board in memory. When the user clicks the New Game button, the application should step through thearray, storing a random number in the range of 0 through 1 in each element. The number 0 represents the letter O, and the number 1 represents the letter X. The application’s windowshould then be updated to display the game board. The application should display a messageindicating whether player X won, player Y won, or the game was a tie
Chapter 11 Solutions
Starting Out with Java: Early Objects (6th Edition)
Ch. 11.1 - What is a user interface?Ch. 11.1 - How does a command line interface work?Ch. 11.1 - Prob. 11.3CPCh. 11.1 - Prob. 11.4CPCh. 11.2 - What is JavaFX?Ch. 11.2 - Prob. 11.6CPCh. 11.2 - Prob. 11.7CPCh. 11.2 - Prob. 11.8CPCh. 11.2 - Prob. 11.9CPCh. 11.2 - Prob. 11.10CP
Ch. 11.2 - What is the purpose of the launch method of the...Ch. 11.2 - What is the purpose of the Application classs...Ch. 11.2 - The program in Code Listing 12-1 calls a Stage...Ch. 11.2 - Prob. 11.14CPCh. 11.3 - What is the general difference between an HBox...Ch. 11.3 - Prob. 11.16CPCh. 11.3 - Prob. 11.17CPCh. 11.3 - How do you change the alignment of an HBox...Ch. 11.3 - Prob. 11.19CPCh. 11.4 - Prob. 11.20CPCh. 11.4 - Prob. 11.21CPCh. 11.4 - Prob. 11.22CPCh. 11.4 - Prob. 11.23CPCh. 11.4 - Prob. 11.24CPCh. 11.5 - Prob. 11.25CPCh. 11.5 - Prob. 11.26CPCh. 11.5 - Prob. 11.27CPCh. 11.5 - Prob. 11.28CPCh. 11.6 - Prob. 11.29CPCh. 11.6 - Prob. 11.30CPCh. 11.6 - Prob. 11.31CPCh. 11.6 - Prob. 11.32CPCh. 11.7 - In what package is the TextField class?Ch. 11.7 - Prob. 11.34CPCh. 11.8 - Prob. 11.35CPCh. 11.9 - Prob. 11.36CPCh. 11.9 - Prob. 11.37CPCh. 11 - Prob. 1MCCh. 11 - This type of control appears as a rectangular...Ch. 11 - Typically, when the user clicks this type of...Ch. 11 - Prob. 4MCCh. 11 - Prob. 5MCCh. 11 - Prob. 6MCCh. 11 - Prob. 7MCCh. 11 - All JavaFX applications must extend the class. a....Ch. 11 - This container arranges its contents in a single,...Ch. 11 - Prob. 10MCCh. 11 - You use this class to actually display an image....Ch. 11 - The EventHandler interface specifies a method...Ch. 11 - Prob. 13MCCh. 11 - Prob. 14MCCh. 11 - Prob. 15TFCh. 11 - Prob. 16TFCh. 11 - Prob. 17TFCh. 11 - Prob. 18TFCh. 11 - Prob. 1FTECh. 11 - Prob. 2FTECh. 11 - Assume hbox is an HBox container: // This code has...Ch. 11 - Prob. 4FTECh. 11 - Prob. 5FTECh. 11 - Prob. 1AWCh. 11 - Prob. 2AWCh. 11 - Prob. 3AWCh. 11 - Prob. 4AWCh. 11 - Prob. 5AWCh. 11 - Prob. 6AWCh. 11 - Prob. 7AWCh. 11 - Prob. 8AWCh. 11 - Prob. 9AWCh. 11 - Prob. 10AWCh. 11 - Prob. 11AWCh. 11 - Prob. 12AWCh. 11 - Prob. 13AWCh. 11 - Assume borderPane is the name of an existing...Ch. 11 - Prob. 1SACh. 11 - What is the purpose of the Application classs...Ch. 11 - What is the purpose of the Application classs...Ch. 11 - Prob. 4SACh. 11 - Prob. 5SACh. 11 - What two classes do you use to display an image?Ch. 11 - Prob. 7SACh. 11 - Prob. 8SACh. 11 - Prob. 9SACh. 11 - Prob. 10SACh. 11 - Prob. 11SACh. 11 - Latin Translator Look at the following list of...Ch. 11 - Name Formatter Create a JavaFX application that...Ch. 11 - Tip, Tax, and Total Create a JavaFX application...Ch. 11 - Property Tax A county collects property taxes on...Ch. 11 - Prob. 5PCCh. 11 - Prob. 6PCCh. 11 - Travel Expenses Create a GUI application that...Ch. 11 - Joes Automotive Joes Automotive performs the...Ch. 11 - Tic-Tac-Toe Simulator Create a JavaFX application...Ch. 11 - Prob. 10PC
Knowledge Booster
Similar questions
- 10. Tic-Tac-Toe Simulator Create a JavaFX application that simulates a game of tic-tac-toe. Figure 15-55 shows an example of the application's GUI. The window shown in the figure uses nine ImageView components to display the Xs and Os. (You will find images for the X and the O in the book's Student Sample Files.) The application should use a two-dimensional int array to simulate the game board in mem- ory. When the user clicks the New Game button, the application should step through the array, storing a random number in the range of 0 through 1 in each element. The number 0 represents the letter O, and the number 1 represents the letter X. The application's window should then be updated to display the game board. The application should display a message indicating whether player X won, player Y won, or the game was a tie. Tic Tac Toe X Wins! New Gamearrow_forwardcreate an image file programmatically. Your image file should be called OnTheFlyPy.ppm and the code you write to create should be in a public static void makePPM() method defined in the provided Main.java class. Your OnTheFlyPy.ppm should be be 100 pixels wide and 100 pixels tall and the PPM header lines should be correct. The first two rows and last two rows in the OnTheFlyPy.ppm should be red (Red=255, Green=0, Blue= 0). The first two columns and last two columns in the OnTheFlyPy.ppm (except for the part that overlaps with the red pixels you created in the previous part) should should be blue (Red=0, Green=0, Blue= 255). The remaining pixels in your OnTheFlyPy.ppm image should be white (Red=255, Green=255, Blue= 255). Here is a picture of what your final image should look like: import java.io.*; public class Main{ public static void main(String[] args) { makePPM(); } public static void makePPM() { } }arrow_forwardYou can also download the image file from https://www.dropbox.com/scl/fi/ztmuke5mlonrb3e0jdpuj/Santa.jpg?rlkey=lfdzstv649h141jolqdh2kagv&dl=0(1) Write a code to change all red color pixels into blue.(2) Write a code to change only the right half of the red hat into blue, using two ifarrow_forward
- Getting Bigger.pdf PDF O File | C:/Users/19377/Downloads/Getting%20Bigger.pdf + Purpose To review more advanced aspects of user interfaces and event handlers Directions Create an interface for a program that looks like the one in the first image below. Then add an event handler to the JSlider that changes the font size of the text in the JTextArea according to the value on the slider, as illustrated in the second image. Note: These directions are intentionally vague. Use the internet and whatever other resources you have available to try to piece together how to do this. Be sure to cite any sources you use as comments in your code. Text Decorator Type here.. Font Size: 25 50 75 100 Text Decorator Type here... Туре Font Size: 25 50 75 100 11:35 AM e Type here to search 28°F Cloudy 2/23/2022 (8)arrow_forwardThe Image List controls are intended to be used to hold small pictures such as icons or thumbnails.True or Falsearrow_forwardSkybox class (M Visual Studios): Modify the skybox class appropriately to handle cube mapping. This involves loading six images for the cube map, setting appropriate texture parameters, and ensuring the normals of the cube model that encoded and runs sucessfully Task: The upload_CubeMap_images() function in the Skybox.cpp file needs to be implemented sucessfully according to the instructions.Instructions: Enable cube mapping: Use glEnable(GL_TEXTURE_CUBE_MAP) to enable cube mapping. Generate a texture ID: Use glGenTextures() to generate a texture ID to hold the cube map. This ID is stored in the tex_buffer_ID member variable of the Skybox class. Bind the texture ID: Use glBindTexture() to bind the texture ID as the current buffer. Make sure to bind it as a cube map using GL_TEXTURE_CUBE_MAP. Load six images: Load all six images into the correct "place" in the cube map. You can use the provided file paths (BMP_NEG_X_FILE_PATH, BMP_NEG_Y_FILE_PATH, etc.) to load the images. (Make sure to…arrow_forward
- For this code please add these features making it be able to : #generate a blank image with black background, picture size is the same as frame #allow it to calculate center point #Draw white circles into the image generated at line 6, diameter is 6arrow_forwardLearn Visual Basic (in Microsoft Visual Studio) yourself and do the following: (1) Have a textbox that can display multiple lines of text.The user can select a simple .txt file (like a notepad file, a file with ASCII code but not formatting characters). Display the content of the file in this textbox. Should have an vertical scrollbar for the textbook. (2) Have an user interface to take the following information: Firstname (String) Lastname (String) Age (integer) Phone (String) Save the file as testdata.dta. Have to buttons - Save and Quit. Save button to save the record to the file. Quit button to close the file.arrow_forward1. Write a program that displays four images along with their label texts in a grid pane, as shown below. You may use the images available in the folder "LabFiles" | Flags Sultanate of Oman Republic of Yemen Kingdom of Saudi Arabia United Arab Emirates Check Point: How the nodes (elements) are arranged in a grid pane? How can you add nodes to the grid pane? 2. Create different versions of this program to test different type of pane layouts.arrow_forward
- Good evening, I am trying to write a video game on python with an animation with pygame import pygame pygame.init() #game windowscreen_width = 700 screen_height = 351 screen = pygame.display.set_mode((screen_width, screen_height))pygame.display.set_caption('Battle of Mr.Thon') #load images#background imagebackground_img = pygame.image.load('C:\Users\evaam\OneDrive - JUNIA Grande école d\'ingénieurs\Prog\image\Background\Background.png.png').convert_alpha() #function for drawing backgrounddef draw_bg(): screen.blit(background_img, (0, 0)) run = Truewhile run: #draw background draw_bg() for event in pygame.event.get(): if event.type ==pygame.QUIT: run=False pygame.display.update() pygame.quit() BUT when I try to run the program python tells me that there is a syntax error for .convert_alpha() and when I delete it, python says that there is a syntax error in the blank line below background_img Kind regards, Cordialy, EAarrow_forwardIn JAVAFX. Any and all help is appreciated, please also show the results with your code. Please see the attached image.arrow_forwardWrite a JavaFX application that creates polyline shapes dynamically using mouse clicks. Each mouse click adds a new line segment to the current polyline from the previous point to the current mouse position. Allow the user to end the current polyline with the double click. And provide a button that clears the window and allows the user to begin again.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT