I am trying to write a javaFx application with multiple images inside a window.
In short, I have an enum class called Candy , and each candy has some properties and a path to the image file representing it.
In the constructor of my javafx.application ( Table ) class, I want to populate a list of arrays with these images, so I have written this so far:
public class Table extends Application { ArrayList<Image> images; @Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("CandyFx"); primaryStage.show(); } public Table() { images = new ArrayList<Image>(); for (Candy candy : Candy.values()) { File file = new File (candy.getImagePath()); Image image = new Image(file.toURI().toString()); images.add(image); } } }
Now every time I want to create an instance of the Table class, the application throws a java.lang.RuntimeException: Internal graphics not initialized yet .
How can I create an initial graphic that seems like I didn’t?
source share