title: how do i change an image in javafx with a button
body: <p>trying to be as clear as possible this program should display 4 cards which are selected at random and then underneath them there is a button that resets the all the cards at random from a deck of 52. however I am confused on how to go about this in the action event. (also as an added bonus i cant seem to get the button to display underneath the cards rather i just end up moving the entire screen away from the cards and button) any help would be gratefully appreciated.</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.scene.Scene;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  import javafx.scene.layout.Pane;
  import javafx.scene.layout.HBox;
  import javafx.stage.Stage;
  import javafx.scene.control.Button;
  import javafx.event.EventHandler;
  import javafx.geometry.Pos;
  import javafx.scene.layout.GridPane;
  import javafx.event.ActionEvent;
  
  public class GenerateCards extends Application {
  
      public static void main(String[] args) {
      Application.launch(args);
  
      }
  public int cardNum(){
       int Num = (int) Math.ceil(Math.random()*52);
       return Num;
  }
      public void start(Stage primaryStage) {
  
          primaryStage.setTitle("Random Card");
  
                  GridPane pane = new GridPane();
                  pane.setAlignment(Pos.CENTER);
                  pane.setHgap(10);
                  pane.setVgap(5);
  
                  // creates button 
                  Button refresh = new Button("Refresh");
                 HBox button = new HBox(10);
                 button.setAlignment(Pos.BOTTOM_CENTER);
                 button.getChildren().add(refresh);
                 pane.getChildren().add(refresh);
  
                 // creates random card images and adds them to pane
                 Image img = new Image("card/"+cardNum()+".png");
                 ImageView imgView = new ImageView(img);
                 pane.add(imgView, 1, 0);
  
                 Image img2= new Image("card/"+cardNum()+".png");
                 ImageView imgView2 = new ImageView(img2);
                 pane.add(imgView2, 2, 0);
  
                 Image img3= new Image("card/"+cardNum()+".png");
                 ImageView imgView3 = new ImageView(img3);
                 pane.add(imgView3, 3, 0);
  
                 Image img4= new Image("card/"+cardNum()+".png");
                 ImageView imgView4 = new ImageView(img4);
                 pane.add(imgView4,4, 0);
                 //create scene
                 Scene scene = new Scene(pane,400,200);
                 primaryStage.setScene(scene);
                 primaryStage.show();
                 refresh.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
                          public void handle(ActionEvent e){
                         // where im confused
                          }
                  });
  
      }
  }   
  </code></pre>