Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

[Regression] Disabled Button retains opacity when enabled #571

Open
abhinayagarwal opened this issue Aug 23, 2019 · 0 comments
Open

[Regression] Disabled Button retains opacity when enabled #571

abhinayagarwal opened this issue Aug 23, 2019 · 0 comments

Comments

@abhinayagarwal
Copy link
Contributor

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 I think its 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";
}
@abhinayagarwal abhinayagarwal changed the title [Regression] Disabled Button keeps opacity when enabled [Regression] Disabled Button retains opacity when enabled Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant