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

Separator orientation pseudoclass states don't appear to fire properly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
      None

      Description

      In investigating RT-37189 I've noticed something a bit weird with Separator CSS. I modified the .separator styles in modena.css (in particular, the '.separator:horizontal .line' and '.separator:vertical .line' rules) to use slightly more ugly colours (see below). When I did this I noticed that even when I was toggling between horizontal and vertical I was not seeing the styles change. I don't know if it is important, but in Separator, when the pseudoclass state changes, the styleHelper is null, so the second part of the pseudoClassStateChanged method doesn't run.

      In the attached screenshot, the vertical separator should not have the colors it has - those are the colors of the horizontal separator.

      Here's the modena.css I modified:
      .separator:horizontal .line {
          -fx-background-color: red;
          -fx-border-color: green transparent transparent transparent,
              blue transparent transparent transparent;
          -fx-border-insets: 0, 1 0 0 0;
      }
      .separator:vertical .line {
          -fx-background-color: lightblue;
          -fx-border-color: transparent transparent transparent orange,
              transparent transparent transparent purple;
          -fx-border-width: 3, 1;
          -fx-border-insets: 0, 0 0 0 1;
      }

      Here's the test application:

      package helloworld;

      import javafx.application.Application;
      import javafx.geometry.Insets;
      import javafx.geometry.Orientation;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Separator;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class VerticalSeparatorFail extends Application {
          @Override
          public void start(Stage primaryStage) throws Exception {
              final Separator separator = new Separator();
              Button b = new Button("Toggle orientation on first Separator");
              b.setOnAction((e) -> separator.setOrientation(separator.getOrientation() == Orientation.VERTICAL ? Orientation.HORIZONTAL : Orientation.VERTICAL));

              final Separator horizontalSeparator = new Separator(Orientation.HORIZONTAL);
              final Separator verticalSeparator = new Separator(Orientation.VERTICAL);
              verticalSeparator.setTranslateX(30);

              VBox group = new VBox(10, b, separator, horizontalSeparator, verticalSeparator);
              group.setPadding(new Insets(10));
              group.setStyle("-fx-border-color: red");
              group.setMaxHeight(Double.MAX_VALUE);
              Scene scene = new Scene(group, 400, 400);
              primaryStage.setScene(scene);
              primaryStage.show();
          }

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dgrieve David Grieve
              Reporter:
              jgiles Jonathan Giles
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: