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

Disabled menu item continue to look disabled after being enabled

    XMLWordPrintable

Details

    • b15
    • 10
    • x86_64
    • generic

    Description

      FULL PRODUCT VERSION :
      java version "10" 2018-03-20
      Java(TM) SE Runtime Environment 18.3 (build 10+46)
      Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.309]

      A DESCRIPTION OF THE PROBLEM :
      If menu item is disabled before shown first time then it will remain drawn as disabled regardless of an actual state. Menu item itself works as expected.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Scenario 1:
      ---------------
      1. Run the application. Button shows "Enable".
      2. Click on Menu, menu item is disabled and does nothing.
      3. Press button, make sure it shows "Disable".
      4. Click on Menu.
      Menu item still looks disabled however it prints "It works" to the console.

      Scenario 2:
      ---------------
      1. Run the application
      2. Press button, make sure it shows "Disable".
      3. Click on Menu, menu item is enabled as works as expected.
      4. Press button, make sure it shows "Enable".
      5. Click on Menu, menu item is disabled and does nothing.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      In both scenarios expected behavior is to draw menu item according to its actual state: disabled or enabled.
      ACTUAL -
      In Scenario 1 menu item is always drawn as disabled regardless of its actual state.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package sample;

      import javafx.application.Application;
      import javafx.beans.property.SimpleBooleanProperty;
      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 Main extends Application {
          private final SimpleBooleanProperty disable = new SimpleBooleanProperty(true);
          private final Button button = new Button(disable.get() ? "Enable" : "Disable");

          private final MenuItem menuItem = new MenuItem("Menu item");
          private final Menu menu = new Menu("Menu", null, menuItem);
          private final MenuBar menuBar = new MenuBar(menu);

          private final BorderPane root = new BorderPane(button, menuBar, null, null, null);

          @Override
          public void start(Stage primaryStage) throws Exception {
              button.setOnAction(event -> {
                  disable.set(!disable.get());
                  button.setText(disable.get() ? "Enable" : "Disable");
              });

              menuItem.setOnAction(event -> System.out.println("It works"));
              menuItem.disableProperty().bind(disable);

              primaryStage.setTitle("Hello World");
              primaryStage.setScene(new Scene(root, 300, 275));
              primaryStage.show();
          }


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

      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              pkbalakr Prem Balakrishnan (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: