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
}
public ArrayList
public class ImageGamw extends Application { private ArrayList
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started