4 Replies Latest reply on Nov 6, 2013 2:10 PM by Nikolai Varankine

    How to change the value of a color picker?

      Hi *,

      I am currently working on a small project and I would like to use the colorpicker. When I initialize the colorpicker the, the widget is updated and shows the correct color, but when I try to change the value at runtime, nothing happens. Did I miss something?

      Many thanks
      package javafx.tests.colorpicker;
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.geometry.Insets;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ColorPicker;
      import javafx.scene.layout.StackPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.stage.Stage;
      public class ColorPickerChangeColor extends Application {
           public static void main(String[] args) {
           public void start(Stage stage) throws Exception {
                VBox vbox = new VBox();
                vbox.setPadding(new Insets(10));
                Button button = new Button("Press me.");
                final ColorPicker colorpicker = new ColorPicker(Color.BLUE);
                button.setOnAction(new EventHandler<ActionEvent>() {
                     public void handle(ActionEvent arg0) {
                          System.out.println("Set color of the picker to yellow.");
                StackPane root = new StackPane();
                Scene scene = new Scene(root, 200, 200);
      Edited by: 963445 on Jan 3, 2013 12:23 PM