Updated : Java code snippet for Slider