### Slider Change Listener Event

An example of creating a Change Listener Event for the B4J Visual Designer Slider View.
This can be accomplished by making use of API methods via a JavaObject (requires the JavaObject library).
Reference: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Slider.html
The change listener event shows the old, new and incremental value.
B4J Visual Designer
Add the Slider View and generate as Member
B4J Code
`Sub Process_Globals
...
Private Slider1 As Slider
Private Label1 As Label
...
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
...
AppInit
...
End Sub`
`Sub AppInit
Label1.Text = ""
'Reference: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Slider.html
'Set the slider properties
Slider1.MinValue = 0
Slider1.MaxValue = 100
Slider1.Value = 50
'Assign a JavaObject as Slider
Dim joSlider As JavaObject = Slider1
'Set additional properties which are not provided by the B4J Visual Designer
joSlider.RunMethod("setBlockIncrement", Array(10.0))
joSlider.RunMethod("setMajorTickUnit", Array(10.0))
joSlider.RunMethod("setMinorTickCount", Array(20))
joSlider.RunMethod("setShowTickLabels", Array(True))
joSlider.RunMethod("setShowTickMarks", Array(True))
joSlider.RunMethod("setValueChanging", Array(True))
joSlider.RunMethod("setSnapToTicks", Array(True))
'Create the Slider Change Listener
'Assign a JavaObject as the Slider Value Property
Dim joPropertyValue As JavaObject = joSlider.RunMethod("valueProperty",Null)
'Define an Object for the Slider ChangeListener event
Dim objChangeListener As Object = joPropertyValue.CreateEvent("javafx.beans.value.ChangeListener","ChangeListener","")
'Add the ChangeListener to the JavaObject Slder Value Property
'The Sub ChangeListener_Event(MethodName As String, Args() As Object) As Object is executed when the Value of the Slider changes
joPropertyValue.RunMethod("addListener", Array(objChangeListener))
End Sub`
`Sub ChangeListener_Event(MethodName As String, Args() As Object) As Object
Label1.Text = $"Slide Value Changed:${CRLF}Old = ${NumberFormat(Args(1), 0,2)}, New = ${NumberFormat(Args(2),0,2)}, Increase=${NumberFormat(Args(2) - Args(1),0,2)}"$
Return Null
End Sub`

Changed: , Category: Slider, File: T6C249M1803.htm, ID: 1803