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

Builders don't add CSS style

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 7u6
    • fx2.1
    • javafx
    • XP, NB 7.1, FX 2.0.3

      Using the Builders to create a JavaFX Node, the style functions throw an error on run time
      Example:


          private Slider getSlider(double min, double max, double value, double width, Orientation or, Property bind, String style) {
              final Slider s = SliderBuilder.create().min(min).max(max).value(value).blockIncrement(0.1).orientation(or).build();
              s.getStyleClass().add(style);

              s.valueProperty().bindBidirectional(bind);
              if (s.getOrientation().equals(Orientation.HORIZONTAL)) {
                  s.setPrefWidth(width);
              } else {
                  s.setPrefHeight(width);
              }
              return s;
          }

      The above code will work because I have to add the style class after the Slider was created..

      It won't work if I do it like so


          private Slider getSlider(double min, double max, double value, double width, Orientation or, Property bind, String style) {
              final Slider s = SliderBuilder.create().style(style).styleclass(style).min(min).max(max).value(value).blockIncrement(0.1).orientation(or).build();
          // s.getStyleClass().add(style);

              s.valueProperty().bindBidirectional(bind);
              if (s.getOrientation().equals(Orientation.HORIZONTAL)) {
                  s.setPrefWidth(width);
              } else {
                  s.setPrefHeight(width);
              }
              return s;
          }

      both .

      .style(style)
      .styleclass(style)

      seem to be ignored...

      Perhaps this is a Netbeans thing ????

            dgrieve David Grieve
            bockymurpjfx bockymurphy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: