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 ????
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 ????