HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

JavaFX Tutorial 14 Slider Event ChangeListener JavaFX

4,054 views April 26, 2020 6:11

Watch on YouTube
ChannelCode Amir

Description from the creator

JavaFX Tutorial 14 Slider Event ChangeListener JavaFX
Code source :
@Override
public void start(Stage primaryStage) {
HBox h = new HBox();
Slider s = new Slider();
s.setPrefSize(500,200);
s.setMin(25);
s.setMax(250);
s.setValue(125);
s.setShowTickLabels(true);
s.setShowTickMarks(true);
Label lb = new Label("Vlolum : "+ s.getValue());
s.valueProperty().addListener(new ChangeListener?Number?() {
@Override
public void changed(ObservableValue?? extends Number? observable, Number oldValue, Number newValue) {
lb.setText("Valom = " + (int)s.getValue());
}
});

h.getChildren().addAll(lb,s);
Scene sc = new Scene(h,600,400);
primaryStage.setScene(sc);
primaryStage.setTitle("Tutorial JavaFX");
primaryStage.show();
}
Libraries Importing :
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

The JavaFX Slider control provides a way for the user to select a value within a given interval by sliding a handle to the desired point representing the desired value. The JavaFX Slider is represented by the JavaFX class javafx.scene.control.Slider. Here is a screenshot of how a JavaFX Slider looks:

About this tutorial

Code Amir published this 6:11 video tutorial on April 26, 2020. It has been watched 4,054 times on YouTube.

Channel
Code Amir
Category
Education
Duration
6:11
Published
April 26, 2020
Views
4,054
Likes
38

Tags

Share

Further reading

  • Using JavaFX UI Controls: Slider | JavaFX 2 Tutorials and ... docs.oracle.com

    16 Slider. In this chapter, you learn how to use sliders in your JavaFX applications to display and interact with a range of numeric values. The Slider control consists of a track and a draggable thumb. It can also incl…

  • JavaFX | Slider Class - GeeksforGeeks geeksforgeeks.org

    A Slider is a Control in JavaFX which is used to display a continuous or discrete range of valid numeric choices and allows the user to interact with the control. A slider is rendered as a vertical or horizontal bar wit…

  • JavaFX Slider Tutorial tutorialkart.com

    JavaFX Slider. JavaFX Slider is a control that can be used to select a value within a interval using a head on a sliding bar. The position of the head on the slider represents the value of the Slider. Following is an ex…

This tutorial in other languages