import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene; import javafx.scene.control.ColorPicker; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Sphere; import javafx.stage.Stage; public class DiffuseColorTestApp extends Application { private ColorPicker diffuseColorPicker; private PhongMaterial material; private Sphere s; @Override public void start(Stage stage) throws Exception { material = new PhongMaterial(); s = new Sphere(2); s.setScaleX(100); s.setScaleY(100); s.setScaleZ(100); s.setMaterial(material); Group root1 = new Group(s); root1.setTranslateX(250); root1.setTranslateY(250); diffuseColorPicker = new ColorPicker(material.getDiffuseColor()); diffuseColorPicker.valueProperty().bindBidirectional(material.diffuseColorProperty()); diffuseColorPicker.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue ov, Color t, Color t1) { System.out.println("color changed" + t1); material.setDiffuseColor(t1); } }); VBox controls = new VBox(); controls.getChildren().addAll(diffuseColorPicker); Group root = new Group(root1, controls); Scene scene = new Scene(root, 500, 500, true); scene.setCamera(new PerspectiveCamera()); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }