public static @NotNull Dimension expandToFitToolbar(@NotNull Dimension size, @NotNull JComponent toolbar) {
    Dimension preferredSize = toolbar.getPreferredSize();
    int minToolbarSize = Math.round(Math.min(preferredSize.width, preferredSize.height) * 1.5f);
    return new Dimension(Math.max(size.width, minToolbarSize), Math.max(size.height, minToolbarSize));
  }
public static @NotNull Dimension expandToFitToolbar(@NotNull Dimension size, @NotNull JComponent toolbar)