title: JavaFX imageview actions
body: <p>I'm trying to build a replica of MineSweeper, to do this I'm trying to setup some premade images (100x100 pixels made in Photoshop) into an imageview and then when clicked hiding it (to reveal the number below). Without much complexity -- Just the image going visible and invisible I am finding a lot of issues and difficulties.</p>
  
  <p>It is likely due to a complete lack of knowledge on Javafx in general but I even following tutorials to the t I am still unable to implement this feature. I will attach to this my Main.Java code, my <code>sample.fxml</code> code (although it's not called anymore), and then the image I'm trying to hide when clicked.</p>
  
  <p>I have done a lot of research on this (past couple of days) and haven't found anything that solves my problems.</p>
  
  <p>Main.java:</p>
  
  <pre><code>package sample;
  
  import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.image.ImageView;
  import javafx.scene.input.MouseEvent;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      ImageView button;
      @Override
      public void start(Stage primaryStage) throws Exception{
          primaryStage.setTitle("MineSweeper XP");
          button = new ImageView();
  
          button.setOnMouseClicked(new EventHandler&lt;MouseEvent&gt;)(){
  
              public void handle(MouseEvent event){
  
              }
          }
  
          StackPane layout = new StackPane();
          layout.getChildren().add(button);
  
          Scene scene = new Scene(layout,1000, 1000);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>sample.fxml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.image.Image?&gt;
  &lt;?import javafx.scene.image.ImageView?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="100.0" prefWidth="100.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1"&gt;
     &lt;children&gt;
        &lt;ImageView fx:id="button" fitHeight="150.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true"&gt;
           &lt;image&gt;
              &lt;Image url="@../textures/Button_Custom.png" /&gt;
           &lt;/image&gt;
        &lt;/ImageView&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/N3NQ4.png" rel="nofollow noreferrer">The "Button" that will be used for all the MineSweeper keys</a></p>
  
  <p>My singular goal at this given moment is to create a window of any size where I can put the button anywhere and then when the user clicks that button it disappears.</p>