title: Add Menu To Top of Button in Java FX
body: <p>I am trying to get the effect of a drop down menu with arbitrary contents in a JavaFX button. Here is what I have so far:</p>
  
  <pre><code>// I'm using a popup, but that isn't owned by the main window
  button1.setOnMouseClicked(e -&gt; {
      final Stage dialog = new Stage();
      dialog.setAlwaysOnTop(true);
      dialog.initModality(Modality.NONE);
      dialog.initStyle(StageStyle.UNDECORATED);
      try {
          VBox popup = (VBox) FXMLLoader.load(Popup.class.getResource("Popup.fxml"));
          Scene scene = new Scene(popup, 50, 100);
          Bounds boundsInScreen = button1.localToScreen(button1.getBoundsInLocal());
          dialog.setX(boundsInScreen.getMinX());
          dialog.setY(boundsInScreen.getMinY() - 100); // This isn't dynamic, so it's bad
          dialog.setScene(scene);
          dialog.show();
      }
      catch (Exception ex) {
          ex.printStackTrace();
      }
  });
  </code></pre>
  
  <p>I was hoping there was a nice way to bundle the button and its associated popup, (which is basically any arbitrary form) in a way where I don't have to keep track of the size of the popup.</p>