List of usage examples for javafx.scene.shape Rectangle prefHeight
public double prefHeight(double width)
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Colors"); Group root = new Group(); Scene scene = new Scene(root, 350, 300, Color.WHITE); Rectangle rectangle = RectangleBuilder.create().x(50).y(50).width(100).height(70).translateY(10).build(); LinearGradient linearGrad = LinearGradientBuilder.create().startX(50).startY(50).endX(50) .endY(50 + rectangle.prefHeight(-1) + 25).proportional(false).cycleMethod(CycleMethod.NO_CYCLE) .stops(new Stop(0.1f, Color.rgb(255, 200, 0, .784)), new Stop(1.0f, Color.rgb(0, 0, 0, .784))) .build();//from w w w. ja v a 2 s.co m rectangle.setFill(linearGrad); root.getChildren().add(rectangle); primaryStage.setScene(scene); primaryStage.show(); }