title: How to call an array of Images
body: <p>So, I am assigned a problem where I have to display, using JavaFX, 4 random cards and a "Refresh" button that shuffles and displays the cards.</p>
  
  <p>The problem stems when I need to display the cards. 
  I'm not entirely sure how to show/display the images. I consulted the textbook and I can't figure out another path to solving this problem as well as consulting a classmate.</p>
  
  <p>I have the deck of card images in another source file (peer's suggestion) within the java project.</p>
  
  <p>Here is what I have so far: </p>
  
  <pre><code>package Images;
  
  import java.util.Arrays;
  import java.util.Collections;
  
  import javafx.application.Application;
  import javafx.geometry.Pos;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.layout.HBox;
  import javafx.stage.Stage;
  
  public class CardRefreshButton extends Application{
  
      Image[] deck = new Image[51];
  
      public void add() {
          for(int i = 0; i &lt; deck.length; i++){
              deck[i] = new Image(i + ".png");
          }
      }
      public void shuffle() {
          Collections.shuffle(Arrays.asList(deck));
  
      }
  
      @Override
      public void start(Stage primaryStage)  {
  
          primaryStage.setTitle("Shuffling Deck Program");
  
          BorderPane bPane1 = new BorderPane();
          HBox pane1 = new HBox(10);
          HBox pane2 = new HBox(10);
  
          Button refresh = new Button("Refresh");
  
          refresh.setOnAction((event) -&gt; {
              add();
              shuffle();
  
              pane1.getChildren().clear();
              start(primaryStage);
          });
  
          pane1.setAlignment(Pos.CENTER);
          pane2.setAlignment(Pos.CENTER);
  
          Image card1 = deck[0];
          Image card2 = deck[1];
          Image card3 = deck[2];
          Image card4 = deck[3];
          ImageView view1 = new ImageView(card1);
          ImageView view2 = new ImageView(card2);
          ImageView view3 = new ImageView(card3);
          ImageView view4 = new ImageView(card4);
  
          pane1.getChildren().addAll(view1,view2,view3,view4);
          pane2.getChildren().add(refresh);
  
          bPane1.setCenter(pane1);
          bPane1.setBottom(pane2);
  
  
          Scene scene1 = new Scene(bPane1, 600,650);
          primaryStage.setScene(scene1);
          primaryStage.show();
  
  
      }
  }
  </code></pre>