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

Disabled Button retains opacity when enabled

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 10, openjfx11, openjfx12, openjfx13
    • Fix Version/s: tbd
    • Component/s: javafx

      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";
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                aghaisas Ajit Ghaisas
                Reporter:
                jvos Johan Vos
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: