JDK-8238587 : Disabled Button retains opacity when enabled
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 10,openjfx11,openjfx12,openjfx13
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2020-02-06
  • Updated: 2020-02-17
  • Resolved: 2020-02-17
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
tbdResolved
Related Reports
Duplicate :  
Description
The opacity property of a custom button, that is initially disabled, is not updated once it has been enabled. The following conditions needs to be met to reproduce the issue:

The custom skin on the button is set using -fx-skin via css stylesheet
The custom button is a part of a layout which has replaced the original root of the Scene
The bug is reproducible with JavaFX 10, 11, 12 but is not reproducible on JDK 9, which is why it seems to be a regression.

It seems to be related to https://bugs.openjdk.java.net/browse/JDK-8201285 and to the issues marked as duplicates / related in the said issue.

REPRODUCIBILITY: This bug can be reproduced always.

SCSS
CustomButtonSkin.java
import javafx.scene.control.Button;
import javafx.scene.control.skin.ButtonSkin;

public class CustomButtonSkin extends ButtonSkin {

    public CustomButtonSkin(Button button) {
        super(button);
    }
}
Main.java
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) {
        BorderPane borderPane = new BorderPane();

        Button button = new Button("Click me!");
        button.setOnAction(e -> {
            Button disabled = new Button("Disabled");
            disabled.setDisable(true);
            Button enable = new Button("Enable");
            enable.setOnAction(ev -> disabled.setDisable(! disabled.isDisable()));
            final HBox root = new HBox(5, enable, disabled);
            root.setAlignment(Pos.CENTER);
            root.getStyleClass().setAll("view");
            borderPane.setCenter(root);
        });

        VBox root = new VBox(20, button);
        root.setAlignment(Pos.CENTER);

        borderPane.setCenter(root);

        final Scene scene = new Scene(borderPane, 300, 275);
        scene.getStylesheets().add(getClass().getResource("custom.css").toExternalForm());
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
custom.css
.view {
}

.button {
    -fx-skin: "sample.CustomButtonSkin";
}
Comments
[~aghaisas] Thank you for the evaluation. Go ahead and close this bug as a duplicate of JDK-8193445.
17-02-2020

Yes. I confirm that the fix for JDK-8193445 fixes this issue.
17-02-2020

My understanding is - processing of CssFlags.REAPPLY for Node : Button@119fd46[styleClass=button]'Disabled' at the end of the log solves the reported issue.
17-02-2020

For this example, here is log of css methods in Node.java with the fix of JDK-8193445 : ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@119fd46[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@62422daa[styleClass=button]'Enable' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@62422daa[styleClass=button]'Enable' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@119fd46[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : HBox@47e08b02[styleClass=view] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="Click me!", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=LCD, fill=0x333333ff] ******** reapplyCSS --- CssFlags.UPDATE ******** Node : Button@6e2bc458[styleClass=button]'Click me!' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : VBox@692f57ec ******** reapplyCSS --- CssFlags.CLEAN ******** Node : HBox@47e08b02[styleClass=view] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@62422daa[styleClass=button]'Enable' --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Button@62422daa[styleClass=button]'Enable' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@119fd46[styleClass=button]'Disabled' --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Button@119fd46[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.DIRTY_BRANCH ******** Node : HBox@47e08b02[styleClass=view] --------------- reapplyCss --- CssFlags.REAPPLY --------- Node : HBox@47e08b02[styleClass=view] --------------- reapplyCss --- CssFlags.UPDATE --------- Node : Button@62422daa[styleClass=button]'Enable' --------------- reapplyCss --- CssFlags.UPDATE --------- Node : Button@119fd46[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.DIRTY_BRANCH ******** Node : Button@62422daa[styleClass=button]'Enable' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.DIRTY_BRANCH ******** Node : Button@119fd46[styleClass=button]'Disabled' --------------- reapplyCss --- CssFlags.REAPPLY --------- Node : Button@62422daa[styleClass=button]'Enable' --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Text[text="Enable", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=LCD, fill=0x000000ff] --------------- reapplyCss --- CssFlags.REAPPLY --------- Node : Button@119fd46[styleClass=button]'Disabled' --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Text[text="Disabled", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=LCD, fill=0x000000ff]
17-02-2020

For this example, here is log of css methods in Node.java without the fix of JDK-8193445 : ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@780eb2b1[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@55b58233[styleClass=button]'Enable' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@55b58233[styleClass=button]'Enable' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@780eb2b1[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : HBox@54b7c8df[styleClass=view] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="Click me!", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=LCD, fill=0x333333ff] ******** reapplyCSS --- CssFlags.UPDATE ******** Node : Button@265ac03b[styleClass=button]'Click me!' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : VBox@4e3c78e7 ******** reapplyCSS --- CssFlags.CLEAN ******** Node : HBox@54b7c8df[styleClass=view] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@55b58233[styleClass=button]'Enable' --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Button@55b58233[styleClass=button]'Enable' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Button@780eb2b1[styleClass=button]'Disabled' --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Button@780eb2b1[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.DIRTY_BRANCH ******** Node : HBox@54b7c8df[styleClass=view] --------------- reapplyCss --- CssFlags.DIRTY_BRANCH --------- Node : HBox@54b7c8df[styleClass=view] --------------- reapplyCss --- CssFlags.UPDATE --------- Node : Button@55b58233[styleClass=button]'Enable' --------------- reapplyCss --- CssFlags.UPDATE --------- Node : Button@780eb2b1[styleClass=button]'Disabled' ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.DIRTY_BRANCH ******** Node : Button@55b58233[styleClass=button]'Enable' --------------- reapplyCss --- CssFlags.DIRTY_BRANCH --------- Node : Button@55b58233[styleClass=button]'Enable' --------------- reapplyCss --- CssFlags.UPDATE --------- Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.CLEAN ******** Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] --------------- reapplyCss --- CssFlags.CLEAN --------- Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff] ******** reapplyCSS --- CssFlags.DIRTY_BRANCH ******** Node : Button@780eb2b1[styleClass=button]'Disabled' --------------- reapplyCss --- CssFlags.DIRTY_BRANCH --------- Node : Button@780eb2b1[styleClass=button]'Disabled' --------------- reapplyCss --- CssFlags.UPDATE --------- Node : Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=13.0], fontSmoothingType=GRAY, fill=0x000000ff]
17-02-2020

We have the same observations (works on tip, fails on e.g. 14-ea+1)
07-02-2020

I can't reproduce this using a local build of JavaFX 14, but I can if I use an older build (I happened to have 14-ea+1 around so I tried that). I bisected the commits between 14+1 and the HEAD of jfx14 and discovered that the following commit has fixed this problem: JDK-8193445 -- JavaFX CSS is applied redundantly leading to significant performance degradation Interestingly enough, even though that was done for performance reasons, it seems to have also fixed this issue (hopefully because the logic is more sound now and not because of some unintended side effect).
07-02-2020

[~aghaisas] Can you validate my findings? Also, can you evaluate why your performance fix has also fixed this functional issue?
07-02-2020