Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!