import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Stop; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class TestLGP extends Application { @Override public void start(Stage stage) { Rectangle r1 = new Rectangle(100, 100, 100, 100); r1.setFill(new LinearGradient(-3000, -3000, -3000, -3000, false, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.BLUE), new Stop(1, Color.GREEN), })); Rectangle r2 = new Rectangle(300, 100, 100, 100); r2.setFill(new LinearGradient(350, 150, 350, 150, false, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.BLUE), new Stop(1, Color.GREEN), })); stage.setScene(new Scene(new Group(r1, r2), 500, 300)); stage.show(); } }