Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8094575

ToolBar dropdown window doesn't let you select an item from a MenuButton

XMLWordPrintable

      If one of the ToolBar items has a drop-down itself, such as a MenuButton, the ToolBar dropdown window becomes unusable, as it gets dismissed as soon as you click on the MenuButton and release the mouse, meaning before you can get to select a MenuItem from it.

      In the sample below, resize the application window such that the ToolBar items no longer fit, click to open the ToolBar drop-down window, and try to select an item from MenuButton.

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.MenuButton;
      import javafx.scene.control.MenuItem;
      import javafx.scene.control.ToolBar;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;

      public class ToolBarDropDown extends Application {

      public static void main(String[] args) {
      Application.launch(args);
      }

      @Override
      public void start(Stage primaryStage) throws Exception {
      Button btn = new Button();
      btn.setText("Button");

      MenuButton menuBtn = new MenuButton();
      menuBtn.setText("MenuButton");

      MenuItem menuItem = new MenuItem("MenuItem");
      menuBtn.getItems().setAll(menuItem);

      ToolBar toolbar = new ToolBar();
      toolbar.getItems().setAll(btn, menuBtn);

      VBox root = new VBox();
      root.getChildren().setAll(toolbar);

      Scene scene = new Scene(root, 300, 100);
      primaryStage.setScene(scene);
      primaryStage.initStyle(StageStyle.UTILITY);
      primaryStage.show();
      }

      }

            jgiles Jonathan Giles
            sbozianjfx Shant Bozian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: