private void setupListeners() {
    onClick.addListener((observable, oldClick, newClick) -> {
      setOnMouseClicked(newClick);
      updateStyleClasses();
    });
    getItems().addListener((InvalidationListener) observable -> updateStyleClasses());
    graphicProperty().addListener((observable, oldIcon, newIcon) -> {
      if (newIcon instanceof ImageView) {
        ImageView imageView = ((ImageView) newIcon);
        imageView.setPreserveRatio(true);

        // Binds the dimensions of the ImageView to the ToolbarItems height.
        imageView.fitHeightProperty().bind(prefHeightProperty().multiply(ICON_RESIZING_FACTOR));
      }
    });

    showingProperty().addListener((observable, wasShowing, isShowing) -> {
      if (!getItems().isEmpty() && isShowing) {
        getItems().get(0).getParentPopup().setStyle("-fx-min-width: " + getWidth());
      }
    });
  }
Creates a new {@link ToolbarItem} which appears like a {@link MenuButton},
using the given {@code text} and {@code graphic} as button menu button content
and the {@code items} as its {@link MenuItem}s.

@param text  the text to be displayed on the {@link ToolbarItem}
@param graphic the graphic to be displayed on the {@link ToolbarItem}
@param items   the items to be displayed in the context-menu of the {@link ToolbarItem}
workbenchfx-core/src/main/java/com/dlsc/workbenchfx/view/controls/ToolbarItem.java