22 March 2021

Color Mixer

       -------------------------
        |  Slider Demo          |
        -------------------------
        |                       |
        | -------o-----------   |
        | 0                100  |
        | --------------------  |
        | | 35                  |
        | --------------------  |
        |                       |
        ------------------------

         -----------------------------------------------
         |  Color Matcher                              |
         -----------------------------------------------
         |     RED         GREEEN       BLUE
         |  -----o----- -----o------ ------o--------   |
         |     7F            35           4A           |
         |---------------------------------------------|
         |                                             |
         |                                             |
         |     field of color                          |
         |                                             |
         |                                             |
         |                                             |
         |                                             |
         |---------------------------------------------|


/**************************************************
*   Author: Morrison
*   Date:  19 Mar 202021
**************************************************/

import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
public class SliderDemo extends Application
{
    private Slider slider;
    private TextField tf;
    public SliderDemo()
    {
        slider = new Slider(0, 100, 50);
        slider.setMajorTickUnit(4);
        slider.setSnapToTicks(true);
        tf = new TextField();
        tf.setText("50");
    }

    @Override
    public void init()
    {
    }

   @Override
    public void start(Stage primary)
    {
        primary.setTitle("Slider Demo");
        VBox vbox = new VBox();
        slider.valueProperty().addListener( (source, oldValue, newValue) ->
        {
            tf.setText("" + slider.getValue());
        });
        vbox.getChildren().addAll(slider, tf);
        primary.setScene(new Scene(vbox, 300, 120));
        primary.show();
    }

    @Override
    public void stop()
    {
    }
}