Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Loading Images Help! I\'m using ImageView on Eclipse to read my jpg image. Howev

ID: 659695 • Letter: L

Question

Loading Images Help!

I'm using ImageView on Eclipse to read my jpg image. However, I am having touble displaying them when I run. Here is my code below:

while ( !myDeck.isEmpty() ) {

           myDeck.shuffle();

               

            Card[] hand = myDeck.draw( 4 );

            for ( int i = 0; i < hand.length; i++ ) {

            String fileName = "file:./playing_cards_images/" +hand[i] +".jpg";

            ImageView imageView = new ImageView(new Image(fileName));

                 imageView.setPreserveRatio(true);

                 imageView.setFitWidth(75);

             System.out.println(imageView);

I'm trying to open images by the string I placed in the array. Here is what it says on the console:

Exception in thread "main" java.lang.RuntimeException: Internal graphics not initialized yet

   at com.sun.glass.ui.Screen.getScreens(Screen.java:70)

   at com.sun.javafx.tk.quantum.QuantumToolkit.getScreens(QuantumToolkit.java:625)

   at com.sun.javafx.tk.quantum.QuantumToolkit.getMaxPixelScale(QuantumToolkit.java:640)

   at com.sun.javafx.tk.quantum.QuantumToolkit.loadImage(QuantumToolkit.java:648)

   at javafx.scene.image.Image.loadImage(Image.java:1036)

   at javafx.scene.image.Image.initialize(Image.java:785)

   at javafx.scene.image.Image.<init>(Image.java:599)

   at test.main(test.java:96)

Explanation / Answer

From What i can see the code u pasted, u are accessing some value with out intilalizing in 70th line of SCREEN.JAVA

try using debugger moder with a break point in 70th line.

Mostly some initializing problem

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote