JDK-8201310 : Disabled menu item continue to look disabled after being enabled
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 10,openjfx11
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-04-08
  • Updated: 2018-05-30
  • Resolved: 2018-05-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx11Resolved
Related Reports
Duplicate :  
Relates :  
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 ----------


Comments
Issue does not occur after reverting the JDK-8177636 patch
23-05-2018

Issue is reproducible and its a regression introduced in JDK 10+b15. Windows 10 JDK results: ------------------------------ 8u172-b11 : Pass 9.0.4+11 : Pass 10+14 : Pass 10+15 : Fail <-- regression introduced here 10+46 : Fail 11-ea+8 : Fail ------------------------------
09-04-2018