I want to put a linear gradient on a line(width wise ie across it's stroke width). This line is a child of a Group node. When I apply linear gradient on line, the color stops are calculated using Group's bounds not the lines bounds. In my code below, linear gradient will show up properly when added length-wise ie "to bottom", but not when added width wise, ie "to right". Can anyone tell me what can be work around for this? Here is the SSCCE
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Group group = new Group();
primaryStage.setScene(new Scene(group, 200, 350));
Line line = new Line(100, 50, 100, 300);
group.getChildren().add(line);
line.setStyle("-fx-stroke-width:3em; -fx-stroke:linear-gradient(to right, red, green);");
//line.setStyle("-fx-stroke-width:3em; -fx-stroke:linear-gradient(to bottom, red, green);");
primaryStage.show();
}
public static void main(String[] args) {
launch();
}
}