The Slider Control is used to display a continuous or discrete range of valid numeric choices and allows the user to interact with the control. It is typically represented visually as having a "track" and a "knob" or "thumb" which is dragged within the track. The Slider can optionally show tick marks and labels indicating the different slider position values.
The three fundamental variables of the slider are min,
max, and value. The value should always
be a number within the range defined by min and
max. min should always be less than or equal to
max (although a slider whose min and
max are equal is a degenerate case that makes no sense).
min defaults to 0, whereas max defaults to 100.
This first example creates a slider whose range, or span, goes from 0 to 1, and whose value defaults to .5:
import javafx.scene.control.Slider; Slider slider = new Slider(0, 1, 0.5);
This next example shows a slider with customized tick marks and tick mark labels, which also spans from 0 to 1:
import javafx.scene.control.Slider; Slider slider = new Slider(0, 1, 0.5); slider.setShowTickMarks(true); slider.setShowTickLabels(true); slider.setMajorTickUnit(0.25f); slider.setBlockIncrement(0.1f);
extends