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.PointLight; import javafx.scene.Scene; import javafx.scene.control.ColorPicker; import javafx.scene.control.ScrollBar; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Sphere; import javafx.stage.Stage; /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ /** * * @author Andrew Glushchenko */ public class SpecularColorTestApp extends Application { private ScrollBar specularPowerScroll; private ColorPicker specularColorPicker; @Override public void start(Stage stage) throws Exception { final PhongMaterial material = new PhongMaterial(Color.ANTIQUEWHITE); Sphere s = new Sphere(); s.setScaleX(100); s.setScaleY(100); s.setScaleZ(100); s.setMaterial(material); Group root1 = new Group(s); root1.setTranslateX(250); root1.setTranslateY(250); specularPowerScroll = new ScrollBar(); specularPowerScroll.setMin(0); specularPowerScroll.setMax(1); specularPowerScroll.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue ov, Number t, Number t1) { material.setSpecularPower(t1.doubleValue()); System.out.println("power changed"); } }); // specularPowerScroll.setValue(material.getSpecularPower()); // specularPowerScroll.valueProperty().bindBidirectional(material.specularPowerProperty()); specularColorPicker = new ColorPicker(material.getSpecularColor()); //specularColorPicker.valueProperty().bindBidirectional(material.specularColorProperty()); specularColorPicker.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue ov, Color t, Color t1) { material.setSpecularColor(t1); System.out.println("color changed"); } }); VBox controls = new VBox(); controls.getChildren().addAll(specularColorPicker, specularPowerScroll); 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); } }