Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language: java Topic: javafx- image objects in ArrayList from another class Question: Create ArrayList of 12 image objects separately in a class called ImageList and

language: java Topic: javafx- image objects in ArrayList from another class

Question: Create ArrayList of 12 image objects separately in a class called ImageList and use them in another class called ImageGame where the images are shown side by side in a row in same javaFx stage. Display the the images once everything is computed.

import javafx.application.Application; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.image.Image; import javafx.scene.image.ImageView; import javafx.geometry.Insets; import javafx.scene.layout.Pane; import java.util.ArrayList; import java.collections.ObservableList:

^import these class above for both classes to work correctly

how the classes should look similar to below. The image file location can be different since it maybe stored somewhere else in your computer

public class ImageList { private ArratList imageList; public ImageList() { imageList = new ArrayList<>(); Image image1 = new Image ("image2.JPG); Image image2 = new Image("image2.JPG); Image image3 = new Image("image3.JPG"); Image image4 = new Image("image4.JPG); imageList.add(image1); imageList.add(image2);

}

public ArrayList getImageList() { return imageList; }

public class ImageGamw extends Application { private ArrayList imageList; private ArrayList imageViews;

public void start(Stage stage) { Pane pane = new Pane();

ImageList imageArray = new ImageList(); imageArray = imageArray.getImageList; for(int I = 0; I < 12; i++) { imageViews.get(i).add(new ImageView(imageArray.get(i))); pane.add(imageViews.get(i); } Scene scene = new scene(pane); stage.setScene(scene); stage.setTitle("image game"); stage.show(); }

public static void main(String[] args) { launch(args): } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions