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

Menu is disappearing on click even when having Menu items in it

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u40
    • Fix Version/s: 9
    • Component/s: javafx
    • Environment:

      Windows 7 b64 bits, JDK 8u40 b17

      Description

      Run this sample program:
      "

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class MenuButtontest extends Application {

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

          @Override
          public void start(Stage stage) {

              MenuBar bar = new MenuBar();

              Button button = new Button("add menu");

              addMenu(bar);

              button.setOnAction((ActionEvent event) -> {
                  addMenu(bar);
              });
              BorderPane pane = new BorderPane(button);
              pane.setTop(bar);
              Scene scene = new Scene(pane);
              stage.setScene(scene);
              stage.show();
          }

          private void addMenu(MenuBar bar) {
              Menu menu = new Menu("test");
              bar.getMenus().add(menu);

              MenuItem item = new MenuItem("Menu item");
              item.setOnAction((ActionEvent event) -> {
                  System.out.println("TEST");
              });

              Menu menu2 = new Menu("menu two");
              menu.getItems().add(menu2);
              menu2.getItems().add(item);
          }
      }
      "
      Click on the "test" Menu in the menuBar. Then click on "menu two" that has appeared. Nothing is happening apart from the "Menu Item" appearing. Clicking on the Menu does nothing, it's normal.

      Now click on "add menu" button which add the exact same Menu next to the previous.

      Now do the exact pattern on the second Menu. You will see that clicking on the "menu two" will make the whole menu disappear.

      So we have a difference in behavior between two exact Menus.
      Any thought?

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              shadzic Samir Hadzic
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: