title: How to add a click event to a tableview cell in javafx
body: <p>My goal is to detect when a user double clicks a cell in the <code>TableView</code> and use the information from that cell. From my picture you can see I will have a table of beers, breweries, and style.</p>
  
  <p>Upon double clicking a cell I want to show the user an image (of the beer, a brewery) with some info. I am using scene builder as well, so I am dealing with controller classes. So far what I have is this but no luck. No errors, just doesn't pull the info when I attempt a basic test.</p>
  
  <p>FYI: I want to detect the click on one cell, and ONLY pull info from the cell clicked - not the entire row.</p>
  
  <p><a href="https://i.stack.imgur.com/ZRszu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZRszu.png" alt="screenshot of table with beers and breweries"></a></p>
  
  <p>Here is my code for the event.</p>
  
  <pre><code>public void clickItem(MouseEvent event) {
      tableID.setOnMouseClicked(new EventHandler&lt;MouseEvent&gt;() {
          @Override
          public void handle(MouseEvent event) {
              System.out.println("Clicked on " + (tableID.getSelectionModel().getSelectedCells().get(0)).getColumn());        
          }
      });
  }
  </code></pre>