package test.scenegraph.app; /** * * @author tester */ import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.ChoiceBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Stop; import javafx.scene.shape.CubicCurve; import javafx.stage.Stage; public class ShortApp extends Application { static final LinearGradient gradientEffect = new LinearGradient(0, 0, 1, 2, true, CycleMethod.REPEAT, new Stop[]{new Stop(0, Color.AQUA), new Stop(0.5f, Color.RED)}); @Override public void start(Stage stage) { final Pane p = new VBox(); Scene scene = new Scene(p); stage.setScene(scene); stage.setWidth(400); stage.setHeight(600); p.setTranslateX(50); p.setTranslateY(50); stage.show(); CubicCurve node = createCurve(); CubicCurve node2 = createCurve(); ChoiceBox cb = new ChoiceBox(); Color blackcolor = Color.BLACK; cb.getItems().add(blackcolor); cb.getItems().add(gradientEffect); cb.getSelectionModel().select(blackcolor); p.getChildren().add(cb); p.getChildren().add(node); p.getChildren().add(node2); node2.setFill(gradientEffect); node.fillProperty().bind(cb.getSelectionModel().selectedItemProperty()); } public static void main(String args[]) { Application.launch(ShortApp.class, args); } CubicCurve createCurve() { CubicCurve node = new CubicCurve(); node.setStartX(0.0f); node.setStartY(50.0f); node.setControlX1(80.0f); node.setControlY1(250.0f); node.setControlX2(60.0f); node.setControlY2(-50.0f); node.setEndX(128.0f); node.setEndY(50.0f); return node; } }