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

[Menu] showing property change listener is not called on showing by keyboard

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7u6
    • fx2.1
    • javafx
    • 2.1.0b15

      Run attached code:


      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.CheckBox;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      /**
       *
       * @author alexandr_kirov
       */
      public class MenuOnShown extends Application {

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

          @Override
          public void start(Stage stage) {
              VBox vb = new VBox();
              MenuBar mb = new MenuBar();

              Menu menu = new Menu("Menu");
              mb.getMenus().add(menu);

              menu.getItems().clear();
              for (int i = 0; i < 5; i++) {
                  menu.getItems().add(new MenuItem("MENU_ITEM" + i));
              }

              final CheckBox cb = new CheckBox("showing");
              menu.showingProperty().addListener(new ChangeListener<Boolean>() {

                  public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                      System.out.println("shown?");
                      cb.selectedProperty().setValue(t1);
                  }
              });

              vb.getChildren().addAll(cb, mb);

              Scene scene = new Scene(vb, 300, 300);
              stage.setScene(scene);
              stage.show();
          }
      }

      On launch, focus is on checkBox.
      Press "Tab"
      Press "Space"
      you will see dropDown.

      But this
              menu.showingProperty().addListener(new ChangeListener<Boolean>() {
      is not called.

      Showing property is not reflect the currecnt state in such case.

      But if you use mouse, and click on menu, than listener will be called.

            psomashe Parvathi Somashekar (Inactive)
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: