A slider with customized tick marks and tick mark labels, which also spans from 0 to 1 : Slider « JavaFX « Java






A slider with customized tick marks and tick mark labels, which also spans from 0 to 1

  
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage stage) {
        Group root = new Group();
        Scene scene = new Scene(root, 600, 400);
        stage.setScene(scene);
        stage.setTitle("Slider Sample");

        Slider slider = new Slider(0, 1, 0.5);
        slider.setShowTickMarks(true);
        slider.setShowTickLabels(true);
        slider.setMajorTickUnit(0.25f);
        slider.setBlockIncrement(0.1f);
        
        root.getChildren().add(slider);

        stage.show();
    }
    public static void main(String[] args) {
        launch(args);
    }
}

   
    
  








Related examples in the same category

1.Using CustomMenuItem to add Slider to MenuItem
2.balance, rate, volume Slider;
3.Slider value property change listener
4.Creates a slider who's range, or span, goes from 0 to 1, and who's value defaults to .5: