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

The graphic of a disabled button is not being rendered correctly under certain conditions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P4
    • 8
    • 7u40
    • javafx

    Description

      Under certain conditions, the graphic of a disabled button is not being rendered correctly: it looks like it is overlapped with another disabled button's graphic, and flickers upon resizing the Window.

      It seems to me that there are multiple factors causing this, but here's at least one scenario which reproduces the problem consistently:
      - I have three buttons in an HBox: A.disabled B.enabled C.disabled
      - The graphic of C looks overlapped with that of A, and flickers upon resizing the Window


      import javafx.application.Application;
      import javafx.beans.binding.Bindings;
      import javafx.geometry.Insets;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ButtonBuilder;
      import javafx.scene.control.ContentDisplay;
      import javafx.scene.control.Label;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.HBoxBuilder;
      import javafx.scene.layout.VBox;
      import javafx.scene.layout.VBoxBuilder;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.CircleBuilder;
      import javafx.scene.shape.RectangleBuilder;
      import javafx.stage.Stage;

      public class DisabledGraphicTest extends Application {

          public DisabledGraphicTest() {
          }


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

          @Override
          public void start(Stage stage) {
              Button goodRedButton = createButton(CircleBuilder.create().fill(Color.RED).radius(8).build());
              goodRedButton.setDisable(true);
              Button goodBlueButton = createButton(RectangleBuilder.create().fill(Color.BLUE).height(16).width(16).build());
              goodBlueButton.setDisable(true);
              HBox goodHBox = HBoxBuilder.create().children(goodRedButton, goodBlueButton).spacing(10).build();
              VBox goodVBox = VBoxBuilder.create().children(new Label("With two consecutive disabled buttons: there's nothing wrong:"), goodHBox).build();

              Button badRedButton = createButton(CircleBuilder.create().fill(Color.RED).radius(8).build());
              badRedButton.setDisable(true);
              Button badGreenButton = createButton(CircleBuilder.create().fill(Color.GREEN).radius(8).build());
              badGreenButton.disableProperty().bind(Bindings.not(badRedButton.visibleProperty()));
              Button badBlueButton = createButton(RectangleBuilder.create().fill(Color.BLUE).height(16).width(16).build());
              badBlueButton.setDisable(true);
              HBox badHBox = HBoxBuilder.create().children(badRedButton, badGreenButton, badBlueButton).spacing(10).build();
              VBox badVBox = VBoxBuilder.create().children(new Label("But with an enbaled button in between, the graphic of the third button is not being rendered correctly:"), new Label("it sort of overlaps with that of the first button, and flickers upon resizing the Window:"), badHBox).build();

              VBox vBox = VBoxBuilder.create().children(goodVBox, badVBox).spacing(200).padding(new Insets(50)).build();

              Scene scene = new Scene(vBox);
              stage.setScene(scene);
              stage.setWidth(660);
              stage.setHeight(500);
              stage.show();
          }

          private Button createButton(Node graphic) {
              return ButtonBuilder.create().contentDisplay(ContentDisplay.GRAPHIC_ONLY).graphic(graphic).build();
          }

      }

      Attachments

        1. image-initial.png
          image-initial.png
          32 kB
        2. image-resize.png
          image-resize.png
          32 kB
        3. screenshot-1.jpg
          screenshot-1.jpg
          34 kB

        Issue Links

          Activity

            People

              kcr Kevin Rushforth
              sbozianjfx Shant Bozian (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: