title: How to bind a JavaFX Slider to a Label that shows values from a List?
body: <p>I have built this <code>Slider</code> using <code>JavaFX</code> which is binded to a <code>Label</code>. At the moment I managed only to make the <code>Slider</code> work on discrete values (from 0 to 15) and to display those values on a <code>Label</code>. I would like to display another kind of values, one for every of those 16 discrete values. Maybe from a list or whatever.
  How can I achieve this?</p>
  
  <p><strong>My implementation</strong></p>
  
  <pre><code>private Slider sampleRateSlider = new Slider (0, 15, 0);
  private Label sampleRateLabel = new Label("Sample Rate");
  private Label sampleRateValueLabel = new 
  Label(Double.toString(sampleRateSlider.getValue()));
  
  acquisitionModeTab.setConstraints(sampleRateLabel,0, 1);
  acquisitionModeTab.setConstraints(sampleRateSlider, 1, 1);
  sampleRateSlider.setShowTickLabels(true);
  sampleRateSlider.setShowTickMarks(true);
  sampleRateSlider.setMajorTickUnit(5);
  sampleRateSlider.setMinorTickCount(5);
  sampleRateSlider.setSnapToTicks(true);
  acquisitionModeTab.setConstraints(sampleRateValueLabel, 2, 1);
  sampleRateValueLabel.setAlignment(Pos.CENTER_RIGHT);
  </code></pre>
  
  <p><strong>Listener inside <code>initialize()</code> method in my controlles class:</strong></p>
  
  <pre><code> sampleRateSlider.valueProperty().addListener((ov, old_val, new_val) -&gt; {
          new_val = Math.round(new_val.doubleValue());
          sampleRateSlider.setValue(new_val.doubleValue());
          System.out.println(new_val.intValue());
          sampleRateValueLabel.setText(new_val.toString());
      });
  </code></pre>
  
  <p>Everything is working, but I would like to achieve what I asked above and I do not know how.</p>